From 7d0d4e2e0df6a344c20dd6d204f9257b8e5175bc Mon Sep 17 00:00:00 2001 From: ache Date: Wed, 4 May 2022 20:39:27 +0200 Subject: Implement Canonical --- src/build/index.mjs | 6 ++++-- src/build/rss.mjs | 13 ++++++------- src/templates/header.tmpl | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/build/index.mjs b/src/build/index.mjs index d96eca3..7b8c8dc 100644 --- a/src/build/index.mjs +++ b/src/build/index.mjs @@ -41,7 +41,6 @@ const loadMD = (listFile, suffix) => { const readMore = h('a', 'Lire plus...'); readMore.properties.href = `${suffix}/${file.slice(0, -3)}`; - readMore.properties.role = 'expend'; readMore.properties.for = domTitle; listContent.push({ @@ -63,6 +62,7 @@ const leftPanelTmpl = fs.readFileSync('src/templates/left.tmpl', 'utf8'); const headerTmpl = fs.readFileSync('src/templates/header.tmpl', 'utf8'); const articleTmpl = fs.readFileSync('src/templates/article.tmpl', 'utf8'); const indexTmpl = fs.readFileSync('src/templates/index.tmpl', 'utf8'); +const baseUrl = 'https://ache.one/'; const partials = { header: headerTmpl, @@ -77,6 +77,7 @@ for (const article of articles) { const context = { svg, title: `${article.title} - ache`, + canonical: article.canonical, content: article.content, domTitle: article.domTitle, }; @@ -87,12 +88,13 @@ for (const article of articles) { } console.log('Create : rss.xml'); -const xmlFeed = getRSS(articles); +const xmlFeed = getRSS(articles, baseUrl); fs.writeFileSync('rss.xml', xmlFeed); { const context = { title: 'ache: Blog personnel', + canonical: baseUrl, svg, articles, }; diff --git a/src/build/rss.mjs b/src/build/rss.mjs index 3ac0588..b2e2f4b 100644 --- a/src/build/rss.mjs +++ b/src/build/rss.mjs @@ -1,17 +1,16 @@ import RSS from 'rss'; -const siteUrl = 'https://ache.one'; - -const getRSS = articles => { +const getRSS = (articles, baseUrl) => { const rssFeed = new RSS({ title: 'ache: Blog personnel', description: 'Programmation, Algorithmique, Système, *pick you poison*', // eslint-disable-next-line camelcase - feed_url: `${siteUrl}/feed.xml`, + feed_url: `${baseUrl}/rss.xml`, + canonical: `${baseUrl}/rss.xml`, // eslint-disable-next-line camelcase - site_url: siteUrl, + site_url: baseUrl, // eslint-disable-next-line camelcase - image_url: `${siteUrl}/ache.svg`, + image_url: `${baseUrl}/ache.svg`, language: 'fr', pubDate: (new Date().toLocaleString()), ttl: '1440', @@ -25,7 +24,7 @@ const getRSS = articles => { description: '
' + article.content + '
', // eslint-disable-next-line camelcase image_url: article.imageUrl, - url: `${siteUrl}/articles/${article.name}`, + url: `${baseUrl}/articles/${article.name}`, guid: article.domTitle, author: 'ache', date: article.metaData.pubDate.toISOString(), diff --git a/src/templates/header.tmpl b/src/templates/header.tmpl index d30cae8..26d43a6 100644 --- a/src/templates/header.tmpl +++ b/src/templates/header.tmpl @@ -2,7 +2,7 @@ {{ title }} - +