From 6234504fbd84b5b3ca971d129589f58f74ee5a07 Mon Sep 17 00:00:00 2001 From: Alexander Kreitner <180843591+Gl4dr3x@users.noreply.github.com> Date: Tue, 1 Dec 2026 14:23:58 +0100 Subject: [PATCH 1/2] fix(route): keep the structure of EasyLife 365 changelog posts The route flattened each post to plain text with every whitespace run collapsed, so headings, numbered lists, bullets and screenshots reached feed readers as one paragraph. The description now carries the post body as HTML with absolute links and image URLs, the availability tags on one line above it, and without anchor links or the contact footer. Only dated post pages become items, which drops the rss.xml, atom.xml and feed.json links that were listed as posts. The date comes from the post's own time element, and detail pages are cached. Co-Authored-By: Claude Opus 5.5 --- lib/routes/easylife365/changelogs.ts | 111 ++++++++++++++++----------- 1 file changed, 68 insertions(+), 43 deletions(-) diff --git a/lib/routes/easylife365/changelogs.ts b/lib/routes/easylife365/changelogs.ts index 565571a101b1..81d0e671eb15 100644 --- a/lib/routes/easylife365/changelogs.ts +++ b/lib/routes/easylife365/changelogs.ts @@ -1,40 +1,65 @@ +import type { CheerioAPI } from 'cheerio'; import { load } from 'cheerio'; +import cache from '@/utils/cache'; import got from '@/utils/got'; +import { parseDate } from '@/utils/parse-date'; -function parseDateFromLink(link: string) { - const match = link.match(/\/changelogs\/(\d{4})\/(\d{2})\/(\d{2})\//); +const rootUrl = 'https://docs.easylife365.cloud'; +const changelogPathPattern = /^\/changelogs\/\d{4}\/\d{2}\/\d{2}\/([^/]+)\/[^/]+\/?$/; + +const productMap: Record = { + collab: 'Collaboration', + identity: 'Identity', + mail: 'Mail', + meet: 'Meet', + tipster: 'Tipster', +}; + +function getProductFromLink(link: string) { + const match = new URL(link).pathname.match(changelogPathPattern); if (!match) { - return; + return ''; } - const [, yyyy, mm, dd] = match; - return new Date(`${yyyy}-${mm}-${dd}T00:00:00Z`).toUTCString(); + return productMap[match[1]] ?? match[1]; } -function cleanDescription(text: string) { - return text - .replaceAll(/\s+/g, ' ') - .replace(/^←\s*Back to Changelog/, '') - .replace(/Have questions\? Reach out to us for more information\.?Contact Us$/i, '') - .trim(); +function parseDateFromLink(link: string) { + const match = link.match(/\/changelogs\/(\d{4})\/(\d{2})\/(\d{2})\//); + return match ? parseDate(`${match[1]}-${match[2]}-${match[3]}T00:00:00Z`) : undefined; } -function getProductFromLink(link: string) { - const match = link.match(/\/changelogs\/\d{4}\/\d{2}\/\d{2}\/([^/]+)\//); - if (!match) { +// Turns the Docusaurus post body into clean, self-contained HTML for feed readers. +function getDescription($: CheerioAPI, link: string) { + const body = $('#__blog-post-container').first(); + if (!body.length) { return ''; } - const productMap: Record = { - collab: 'Collaboration', - identity: 'Identity', - mail: 'Mail', - meet: 'Meet', - tipster: 'Tipster', - }; - - return productMap[match[1]] ?? match[1]; + body.find('a.hash-link').remove(); + body.find('[class]').removeAttr('class'); + body.find('img').removeAttr('decoding').removeAttr('loading'); + body.find('a[href]').each((_, el) => { + const href = $(el).attr('href'); + if (href) { + $(el).attr('href', new URL(href, link).toString()); + } + }); + body.find('img[src]').each((_, el) => { + const src = $(el).attr('src'); + if (src) { + $(el).attr('src', new URL(src, link).toString()); + } + }); + + const availability = $('.product-intro li') + .toArray() + .map((el) => $(el).text().trim()) + .filter(Boolean); + const availabilityHtml = availability.length ? `

${availability.join(' · ')}

` : ''; + + return `${availabilityHtml}${body.html()?.trim() ?? ''}`; } export const route = { @@ -44,7 +69,6 @@ export const route = { example: '/easylife365/changelogs', maintainers: ['dein-github-name'], handler: async () => { - const rootUrl = 'https://docs.easylife365.cloud'; const currentUrl = `${rootUrl}/changelogs`; const response = await got(currentUrl); @@ -56,29 +80,30 @@ export const route = { .toArray() .map((el) => $(el).attr('href')) .filter((href): href is string => typeof href === 'string' && href.length > 0) - .map((href) => new URL(href, rootUrl).toString()) + .map((href) => new URL(href, rootUrl)) + .filter((url) => url.origin === rootUrl && changelogPathPattern.test(url.pathname)) + .map((url) => `${url.origin}${url.pathname.replace(/\/$/, '')}`) ), ]; const item = await Promise.all( - links.map(async (link) => { - const detailResponse = await got(link); - const detail$ = load(detailResponse.data); - - const rawTitle = detail$('main h1').first().text().trim() || detail$('h1').first().text().trim() || detail$('title').first().text().trim() || link.split('/').at(-1) || 'Untitled'; - - const product = getProductFromLink(link); - const title = product ? `${product}: ${rawTitle}` : rawTitle; - - const rawDescription = detail$('main').first().text() || detail$('article').first().text() || ''; - - return { - title, - link, - description: cleanDescription(rawDescription), - pubDate: parseDateFromLink(link), - }; - }) + links.map((link) => + cache.tryGet(link, async () => { + const detailResponse = await got(link); + const detail$ = load(detailResponse.data); + + const rawTitle = detail$('main h1').first().text().trim() || detail$('title').first().text().trim() || link.split('/').at(-1) || 'Untitled'; + const product = getProductFromLink(link); + const datetime = detail$('main time[datetime]').first().attr('datetime'); + + return { + title: product ? `${product}: ${rawTitle}` : rawTitle, + link, + description: getDescription(detail$, link), + pubDate: datetime ? parseDate(datetime) : parseDateFromLink(link), + }; + }) + ) ); return { From 6473793fe6bbf3f5dee871a09d5b38f834e6e074 Mon Sep 17 00:00:00 2001 From: Alexander Kreitner <180843591+Gl4dr3x@users.noreply.github.com> Date: Tue, 1 Dec 2026 14:34:18 +0100 Subject: [PATCH 2/2] refactor(route): trim the EasyLife 365 changelog route The output middleware already resolves relative links and media URLs against the item link, so the route no longer does it itself. One path pattern now yields both the product and the date, which removes the branches the link filter made unreachable, and detail pages are fetched five at a time instead of all 132 at once. Co-Authored-By: Claude Opus 5.5 --- lib/routes/easylife365/changelogs.ts | 79 +++++++++------------------- 1 file changed, 24 insertions(+), 55 deletions(-) diff --git a/lib/routes/easylife365/changelogs.ts b/lib/routes/easylife365/changelogs.ts index 81d0e671eb15..d3952eab2810 100644 --- a/lib/routes/easylife365/changelogs.ts +++ b/lib/routes/easylife365/changelogs.ts @@ -1,12 +1,13 @@ import type { CheerioAPI } from 'cheerio'; import { load } from 'cheerio'; +import pMap from 'p-map'; import cache from '@/utils/cache'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; const rootUrl = 'https://docs.easylife365.cloud'; -const changelogPathPattern = /^\/changelogs\/\d{4}\/\d{2}\/\d{2}\/([^/]+)\/[^/]+\/?$/; +const changelogPathPattern = /^\/changelogs\/(\d{4})\/(\d{2})\/(\d{2})\/([^/]+)\/[^/]+\/?$/; const productMap: Record = { collab: 'Collaboration', @@ -16,42 +17,13 @@ const productMap: Record = { tipster: 'Tipster', }; -function getProductFromLink(link: string) { - const match = new URL(link).pathname.match(changelogPathPattern); - if (!match) { - return ''; - } - - return productMap[match[1]] ?? match[1]; -} - -function parseDateFromLink(link: string) { - const match = link.match(/\/changelogs\/(\d{4})\/(\d{2})\/(\d{2})\//); - return match ? parseDate(`${match[1]}-${match[2]}-${match[3]}T00:00:00Z`) : undefined; -} - -// Turns the Docusaurus post body into clean, self-contained HTML for feed readers. -function getDescription($: CheerioAPI, link: string) { +// Turns the Docusaurus post body into clean HTML for feed readers. +// Relative links and image URLs are resolved by the output middleware. +function getDescription($: CheerioAPI) { const body = $('#__blog-post-container').first(); - if (!body.length) { - return ''; - } - body.find('a.hash-link').remove(); body.find('[class]').removeAttr('class'); - body.find('img').removeAttr('decoding').removeAttr('loading'); - body.find('a[href]').each((_, el) => { - const href = $(el).attr('href'); - if (href) { - $(el).attr('href', new URL(href, link).toString()); - } - }); - body.find('img[src]').each((_, el) => { - const src = $(el).attr('src'); - if (src) { - $(el).attr('src', new URL(src, link).toString()); - } - }); + body.find('img').removeAttr('decoding loading'); const availability = $('.product-intro li') .toArray() @@ -74,36 +46,33 @@ export const route = { const response = await got(currentUrl); const $ = load(response.data); - const links = [ - ...new Set( - $('a[href*="/changelogs/"]') - .toArray() - .map((el) => $(el).attr('href')) - .filter((href): href is string => typeof href === 'string' && href.length > 0) - .map((href) => new URL(href, rootUrl)) - .filter((url) => url.origin === rootUrl && changelogPathPattern.test(url.pathname)) - .map((url) => `${url.origin}${url.pathname.replace(/\/$/, '')}`) - ), - ]; + const posts = new Map(); + for (const el of $('a[href*="/changelogs/"]').toArray()) { + const url = new URL($(el).attr('href') ?? '', rootUrl); + const match = url.pathname.match(changelogPathPattern); + if (url.origin === rootUrl && match) { + posts.set(`${url.origin}${url.pathname.replace(/\/$/, '')}`, match); + } + } - const item = await Promise.all( - links.map((link) => + const item = await pMap( + [...posts], + ([link, [, yyyy, mm, dd, product]]) => cache.tryGet(link, async () => { const detailResponse = await got(link); const detail$ = load(detailResponse.data); - const rawTitle = detail$('main h1').first().text().trim() || detail$('title').first().text().trim() || link.split('/').at(-1) || 'Untitled'; - const product = getProductFromLink(link); - const datetime = detail$('main time[datetime]').first().attr('datetime'); + const rawTitle = detail$('main h1').first().text().trim() || detail$('title').first().text().trim() || link.split('/').at(-1); + const datetime = detail$('main time[datetime]').first().attr('datetime') ?? `${yyyy}-${mm}-${dd}T00:00:00Z`; return { - title: product ? `${product}: ${rawTitle}` : rawTitle, + title: `${productMap[product] ?? product}: ${rawTitle}`, link, - description: getDescription(detail$, link), - pubDate: datetime ? parseDate(datetime) : parseDateFromLink(link), + description: getDescription(detail$), + pubDate: parseDate(datetime), }; - }) - ) + }), + { concurrency: 5 } ); return {