From f36945020c049c69c89631087826dca493ac7b3d Mon Sep 17 00:00:00 2001 From: Guest Date: Fri, 1 Nov 2024 16:52:22 +0800 Subject: [PATCH 1/2] feat: support to build article page w/o header --- bin/build-demo.ts | 15 +++++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- src/render/views/article/header.njk | 16 +++++++++++----- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/bin/build-demo.ts b/bin/build-demo.ts index caf1036..c8b13d5 100644 --- a/bin/build-demo.ts +++ b/bin/build-demo.ts @@ -27,6 +27,21 @@ makeArticlePage(MOCK_ARTICLE_PAGE_DATA).then((data) => { fs.writeFileSync(path.resolve(paths.out, 'article.html'), content) }) +// article page without RSS/JSON header +makeArticlePage({ + ...MOCK_ARTICLE_PAGE_DATA, + rss: undefined, + byline: { + ...MOCK_ARTICLE_PAGE_DATA.byline, + author: { ...MOCK_ARTICLE_PAGE_DATA.byline.author, ipnsKey: undefined }, + }, +}).then((data) => { + const content = data.bundle[0]?.content.toString() || '' + + fs.promises.mkdir(paths.out, { recursive: true }).catch(console.error) + fs.writeFileSync(path.resolve(paths.out, 'article-no-header.html'), content) +}) + // encrypted article page makeArticlePage({ ...MOCK_ARTICLE_PAGE_DATA, encrypted: true }).then((data) => { const content = data.bundle[0]?.content.toString() || '' diff --git a/package-lock.json b/package-lock.json index 91b48d2..b82e8c3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@matters/ipns-site-generator", - "version": "0.1.6", + "version": "0.1.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@matters/ipns-site-generator", - "version": "0.1.6", + "version": "0.1.7", "license": "Apache-2.0", "dependencies": { "@matters/slugify": "^0.7.3", diff --git a/package.json b/package.json index e3d1825..6815de7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@matters/ipns-site-generator", - "version": "0.1.6", + "version": "0.1.7", "description": "IPNS site generator for matters.town", "author": "https://github.com/thematters ", "homepage": "https://github.com/thematters/ipns-site-generator", diff --git a/src/render/views/article/header.njk b/src/render/views/article/header.njk index f78af9a..5eb9311 100644 --- a/src/render/views/article/header.njk +++ b/src/render/views/article/header.njk @@ -1,15 +1,21 @@
-
- + {% if rss or byline.author.ipnsKey %} +
+ {% include "../shared/icons/back.njk" %} View All Articles - -
+ +
+ {% endif %}

{{ article.title }}

From 2f02eec5955c6dc04bd72afdc6d8334d3633fd85 Mon Sep 17 00:00:00 2001 From: gitwoz <177856586+gitwoz@users.noreply.github.com> Date: Fri, 1 Nov 2024 16:56:42 +0800 Subject: [PATCH 2/2] fix: snapshots --- .../makeArticlePage.test.js.snap | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/__tests__/__snapshots__/makeArticlePage.test.js.snap b/src/__tests__/__snapshots__/makeArticlePage.test.js.snap index 0aab6f0..755e83f 100644 --- a/src/__tests__/__snapshots__/makeArticlePage.test.js.snap +++ b/src/__tests__/__snapshots__/makeArticlePage.test.js.snap @@ -506,7 +506,8 @@ article li {
-
- + +
+ View All Articles - -
+ +
+

Excepteur in consequat mollit consectetur.

@@ -1273,7 +1277,8 @@ article li {
-
- + +
+ View All Articles - -
+ +
+

Excepteur in consequat mollit consectetur.

@@ -2040,7 +2048,8 @@ article li {
-
- + +
+ View All Articles - -
+ +
+

Excepteur in consequat mollit consectetur.