Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support to build article page w/o header #159

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions bin/build-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() || ''
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"homepage": "https://github.com/thematters/ipns-site-generator",
Expand Down
42 changes: 27 additions & 15 deletions src/__tests__/__snapshots__/makeArticlePage.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,8 @@ article li {
<main>
<header>
<nav>
<section class=\\"rssEntrances\\">

<section class=\\"rssEntrances\\">
<ul>

<li>
Expand All @@ -533,6 +534,7 @@ article li {
</ul>
</section>


<section class=\\"themeSwitch\\">
<button class=\\"light\\" type=\\"button\\" aira-label=\\"switch to dark mode\\">
<svg width=\\"20\\" height=\\"20\\" viewBox=\\"0 0 20 20\\" fill=\\"none\\" xmlns=\\"http://www.w3.org/2000/svg\\">
Expand All @@ -553,15 +555,17 @@ article li {

</nav>

<section class=\\"backToHomepage\\">
<a href=\\"../\\" data-link-type=\\"back-to-article\\">

<section class=\\"backToHomepage\\">
<a href=\\"../\\" data-link-type=\\"back-to-article\\">
<svg width=\\"16\\" height=\\"16\\" viewBox=\\"0 0 16 16\\" xmlns=\\"http://www.w3.org/2000/svg\\">
<path d=\\"M10.5303 3.53033C10.8232 3.23744 10.8232 2.76256 10.5303 2.46967C10.2374 2.17678 9.76256 2.17678 9.46967 2.46967L10.5303 3.53033ZM5 8L4.46967 7.46967C4.17678 7.76256 4.17678 8.23744 4.46967 8.53033L5 8ZM9.46967 13.5303C9.76256 13.8232 10.2374 13.8232 10.5303 13.5303C10.8232 13.2374 10.8232 12.7626 10.5303 12.4697L9.46967 13.5303ZM9.46967 2.46967L4.46967 7.46967L5.53033 8.53033L10.5303 3.53033L9.46967 2.46967ZM4.46967 8.53033L9.46967 13.5303L10.5303 12.4697L5.53033 7.46967L4.46967 8.53033Z\\" fill=\\"currentColor\\"/>
</svg>

View All Articles
</a>
</section>
</a>
</section>


<h1 itemprop=\\"headline\\">Excepteur in consequat mollit consectetur.</h1>

Expand Down Expand Up @@ -1273,7 +1277,8 @@ article li {
<main>
<header>
<nav>
<section class=\\"rssEntrances\\">

<section class=\\"rssEntrances\\">
<ul>

<li>
Expand All @@ -1300,6 +1305,7 @@ article li {
</ul>
</section>


<section class=\\"themeSwitch\\">
<button class=\\"light\\" type=\\"button\\" aira-label=\\"switch to dark mode\\">
<svg width=\\"20\\" height=\\"20\\" viewBox=\\"0 0 20 20\\" fill=\\"none\\" xmlns=\\"http://www.w3.org/2000/svg\\">
Expand All @@ -1320,15 +1326,17 @@ article li {

</nav>

<section class=\\"backToHomepage\\">
<a href=\\"../\\" data-link-type=\\"back-to-article\\">

<section class=\\"backToHomepage\\">
<a href=\\"../\\" data-link-type=\\"back-to-article\\">
<svg width=\\"16\\" height=\\"16\\" viewBox=\\"0 0 16 16\\" xmlns=\\"http://www.w3.org/2000/svg\\">
<path d=\\"M10.5303 3.53033C10.8232 3.23744 10.8232 2.76256 10.5303 2.46967C10.2374 2.17678 9.76256 2.17678 9.46967 2.46967L10.5303 3.53033ZM5 8L4.46967 7.46967C4.17678 7.76256 4.17678 8.23744 4.46967 8.53033L5 8ZM9.46967 13.5303C9.76256 13.8232 10.2374 13.8232 10.5303 13.5303C10.8232 13.2374 10.8232 12.7626 10.5303 12.4697L9.46967 13.5303ZM9.46967 2.46967L4.46967 7.46967L5.53033 8.53033L10.5303 3.53033L9.46967 2.46967ZM4.46967 8.53033L9.46967 13.5303L10.5303 12.4697L5.53033 7.46967L4.46967 8.53033Z\\" fill=\\"currentColor\\"/>
</svg>

View All Articles
</a>
</section>
</a>
</section>


<h1 itemprop=\\"headline\\">Excepteur in consequat mollit consectetur.</h1>

Expand Down Expand Up @@ -2040,7 +2048,8 @@ article li {
<main>
<header>
<nav>
<section class=\\"rssEntrances\\">

<section class=\\"rssEntrances\\">
<ul>

<li>
Expand All @@ -2067,6 +2076,7 @@ article li {
</ul>
</section>


<section class=\\"themeSwitch\\">
<button class=\\"light\\" type=\\"button\\" aira-label=\\"switch to dark mode\\">
<svg width=\\"20\\" height=\\"20\\" viewBox=\\"0 0 20 20\\" fill=\\"none\\" xmlns=\\"http://www.w3.org/2000/svg\\">
Expand All @@ -2087,15 +2097,17 @@ article li {

</nav>

<section class=\\"backToHomepage\\">
<a href=\\"../\\" data-link-type=\\"back-to-article\\">

<section class=\\"backToHomepage\\">
<a href=\\"../\\" data-link-type=\\"back-to-article\\">
<svg width=\\"16\\" height=\\"16\\" viewBox=\\"0 0 16 16\\" xmlns=\\"http://www.w3.org/2000/svg\\">
<path d=\\"M10.5303 3.53033C10.8232 3.23744 10.8232 2.76256 10.5303 2.46967C10.2374 2.17678 9.76256 2.17678 9.46967 2.46967L10.5303 3.53033ZM5 8L4.46967 7.46967C4.17678 7.76256 4.17678 8.23744 4.46967 8.53033L5 8ZM9.46967 13.5303C9.76256 13.8232 10.2374 13.8232 10.5303 13.5303C10.8232 13.2374 10.8232 12.7626 10.5303 12.4697L9.46967 13.5303ZM9.46967 2.46967L4.46967 7.46967L5.53033 8.53033L10.5303 3.53033L9.46967 2.46967ZM4.46967 8.53033L9.46967 13.5303L10.5303 12.4697L5.53033 7.46967L4.46967 8.53033Z\\" fill=\\"currentColor\\"/>
</svg>

View All Articles
</a>
</section>
</a>
</section>


<h1 itemprop=\\"headline\\">Excepteur in consequat mollit consectetur.</h1>

Expand Down
16 changes: 11 additions & 5 deletions src/render/views/article/header.njk
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<header>
<nav>
{% include "../shared/rssEntrances.njk" %}
{% if rss or byline.author.ipnsKey %}
{% include "../shared/rssEntrances.njk" %}
{% else %}
<span></span>
{% endif %}
{% include "../shared/themeSwitch.njk" %}
</nav>

<section class="backToHomepage">
<a href="../" data-link-type="back-to-article">
{% if rss or byline.author.ipnsKey %}
<section class="backToHomepage">
<a href="../" data-link-type="back-to-article">
{% include "../shared/icons/back.njk" %}
View All Articles
</a>
</section>
</a>
</section>
{% endif %}

<h1 itemprop="headline">{{ article.title }}</h1>

Expand Down
Loading