From 032dc3c5e6d0ef84a9f4ea6be10e19b7f43c53b8 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 18 Mar 2023 19:42:37 +0900 Subject: feat(content): add /tags/ page --- nuldoc-src/commands/build.ts | 19 +++- nuldoc-src/pages/tag.ts | 7 +- nuldoc-src/pages/tag_list.ts | 76 +++++++++++++ public/404.html | 2 +- public/about/index.html | 2 +- public/posts/2021-03-05/my-first-post/index.html | 2 +- public/posts/2021-03-30/phperkaigi-2021/index.html | 2 +- .../index.html | 2 +- .../python-unbound-local-error/index.html | 2 +- .../ruby-detect-running-implementation/index.html | 2 +- .../ruby-then-keyword-and-case-in/index.html | 2 +- .../rust-where-are-primitive-types-from/index.html | 2 +- .../index.html | 2 +- .../vim-swap-order-of-selected-lines/index.html | 2 +- .../2022-04-09/phperkaigi-2022-tokens/index.html | 2 +- .../index.html | 2 +- public/posts/2022-05-01/phperkaigi-2022/index.html | 2 +- .../php-conference-okinawa-code-golf/index.html | 2 +- .../index.html | 2 +- .../index.html | 2 +- .../phperkaigi-2023-unused-token-quiz-1/index.html | 2 +- .../setup-server-for-this-site/index.html | 2 +- .../phperkaigi-2023-unused-token-quiz-2/index.html | 2 +- .../phperkaigi-2023-unused-token-quiz-3/index.html | 2 +- .../rewrite-this-blog-generator/index.html | 2 +- public/posts/index.html | 2 +- public/style.css | 3 +- public/tags/conference/index.html | 2 +- public/tags/cpp/index.html | 2 +- public/tags/cpp17/index.html | 2 +- public/tags/index.html | 122 +++++++++++++++++++++ public/tags/note-to-self/index.html | 2 +- public/tags/php/index.html | 2 +- public/tags/phpcon/index.html | 2 +- public/tags/phperkaigi/index.html | 2 +- public/tags/python/index.html | 2 +- public/tags/python3/index.html | 2 +- public/tags/ruby/index.html | 2 +- public/tags/ruby3/index.html | 2 +- public/tags/rust/index.html | 2 +- public/tags/vim/index.html | 2 +- static/style.css | 3 +- 42 files changed, 260 insertions(+), 42 deletions(-) create mode 100644 nuldoc-src/pages/tag_list.ts create mode 100644 public/tags/index.html diff --git a/nuldoc-src/commands/build.ts b/nuldoc-src/commands/build.ts index d523861..911ff50 100644 --- a/nuldoc-src/commands/build.ts +++ b/nuldoc-src/commands/build.ts @@ -13,12 +13,14 @@ import { PostPage, } from "../pages/post.ts"; import { generatePostListPage } from "../pages/post_list.ts"; -import { generateTagPage } from "../pages/tag.ts"; +import { generateTagPage, TagPage } from "../pages/tag.ts"; +import { generateTagListPage } from "../pages/tag_list.ts"; export async function runBuildCommand(config: Config) { const posts = await buildPostPages(config); await buildPostListPage(posts, config); - await buildTagPages(posts, config); + const tags = await buildTagPages(posts, config); + await buildTagListPage(tags, config); await buildAboutPage(config); await buildNotFoundPage(config); await copyStaticFiles(config); @@ -71,12 +73,23 @@ async function buildNotFoundPage(config: Config) { await writePage(notFoundPage, config); } -async function buildTagPages(posts: PostPage[], config: Config) { +async function buildTagPages( + posts: PostPage[], + config: Config, +): Promise { const tagsAndPosts = collectTags(posts); + const tags = []; for (const [tag, posts] of tagsAndPosts) { const tagPage = await generateTagPage(tag, posts, config); await writePage(tagPage, config); + tags.push(tagPage); } + return tags; +} + +async function buildTagListPage(tags: TagPage[], config: Config) { + const tagListPage = await generateTagListPage(tags, config); + await writePage(tagListPage, config); } function collectTags(posts: PostPage[]): [string, PostPage[]][] { diff --git a/nuldoc-src/pages/tag.ts b/nuldoc-src/pages/tag.ts index c9eaf7e..b6f136a 100644 --- a/nuldoc-src/pages/tag.ts +++ b/nuldoc-src/pages/tag.ts @@ -6,7 +6,10 @@ import { el, text } from "../dom.ts"; import { Page } from "../page.ts"; import { getPostCreatedDate, getPostUpdatedDate, PostPage } from "./post.ts"; -export type TagPage = Page; +export interface TagPage extends Page { + tagSlug: string; + tagLabel: string; +} export async function generateTagPage( tagSlug: string, @@ -87,5 +90,7 @@ export async function generateTagPage( renderer: "html", destFilePath: `/tags/${tagSlug}/index.html`, href: `/tags/${tagSlug}/`, + tagSlug: tagSlug, + tagLabel: tagLabel, }; } diff --git a/nuldoc-src/pages/tag_list.ts b/nuldoc-src/pages/tag_list.ts new file mode 100644 index 0000000..e4e53f0 --- /dev/null +++ b/nuldoc-src/pages/tag_list.ts @@ -0,0 +1,76 @@ +import { globalFooter } from "../components/global_footer.ts"; +import { globalHeader } from "../components/global_header.ts"; +import { pageLayout } from "../components/page_layout.ts"; +import { Config } from "../config.ts"; +import { el, text } from "../dom.ts"; +import { Page } from "../page.ts"; +import { TagPage } from "./tag.ts"; + +export type TagListPage = Page; + +export async function generateTagListPage( + tags: TagPage[], + config: Config, +): Promise { + const pageTitle = "タグ一覧"; + + const body = el( + "body", + [["class", "list"]], + globalHeader(config), + el( + "main", + [["class", "main"]], + el( + "header", + [["class", "page-header"]], + el( + "h1", + [], + text(pageTitle), + ), + ), + ...Array.from(tags).sort((a, b) => { + const ta = a.tagSlug; + const tb = b.tagSlug; + if (ta > tb) return -1; + if (ta < tb) return 1; + return 0; + }).map((tag) => + el( + "article", + [["class", "post-entry"]], + el( + "a", + [["href", tag.href]], + el( + "header", + [["class", "entry-header"]], + el("h2", [], text(tag.tagLabel)), + ), + ), + ) + ), + ), + globalFooter(config), + ); + + const html = await pageLayout( + { + metaCopyrightYear: config.blog.siteCopyrightYear, + metaDescription: "タグの一覧", + metaKeywords: [], + metaTitle: pageTitle, + requiresSyntaxHighlight: false, + }, + body, + config, + ); + + return { + root: el("__root__", [], html), + renderer: "html", + destFilePath: "/tags/index.html", + href: "/tags/", + }; +} diff --git a/public/404.html b/public/404.html index 61c347a..96f7478 100644 --- a/public/404.html +++ b/public/404.html @@ -8,7 +8,7 @@ Page Not Found | REPL: Rest-Eat-Program Loop - +
diff --git a/public/about/index.html b/public/about/index.html index 5d59946..686e1c3 100644 --- a/public/about/index.html +++ b/public/about/index.html @@ -8,7 +8,7 @@ About | REPL: Rest-Eat-Program Loop - +
diff --git a/public/posts/2021-03-05/my-first-post/index.html b/public/posts/2021-03-05/my-first-post/index.html index 8821368..65f311d 100644 --- a/public/posts/2021-03-05/my-first-post/index.html +++ b/public/posts/2021-03-05/my-first-post/index.html @@ -8,7 +8,7 @@ My First Post | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2021-03-30/phperkaigi-2021/index.html b/public/posts/2021-03-30/phperkaigi-2021/index.html index 9f3cd92..d31dc5e 100644 --- a/public/posts/2021-03-30/phperkaigi-2021/index.html +++ b/public/posts/2021-03-30/phperkaigi-2021/index.html @@ -9,7 +9,7 @@ PHPerKaigi 2021 | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html b/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html index 91b9ec1..74ad22d 100644 --- a/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html +++ b/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html @@ -9,7 +9,7 @@ 【C++】 属性構文の属性名にはキーワードが使える | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2021-10-02/python-unbound-local-error/index.html b/public/posts/2021-10-02/python-unbound-local-error/index.html index 8380acb..f3b94f3 100644 --- a/public/posts/2021-10-02/python-unbound-local-error/index.html +++ b/public/posts/2021-10-02/python-unbound-local-error/index.html @@ -9,7 +9,7 @@ 【Python】 クロージャとUnboundLocalError: local variable 'x' referenced before assignment | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2021-10-02/ruby-detect-running-implementation/index.html b/public/posts/2021-10-02/ruby-detect-running-implementation/index.html index f0e3632..3930722 100644 --- a/public/posts/2021-10-02/ruby-detect-running-implementation/index.html +++ b/public/posts/2021-10-02/ruby-detect-running-implementation/index.html @@ -9,7 +9,7 @@ 【Ruby】 自身を実行している処理系の種類を判定する | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html b/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html index 55bf07d..0a6d935 100644 --- a/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html +++ b/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html @@ -9,7 +9,7 @@ 【Ruby】 then キーワードと case in | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html b/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html index db9120e..7f1e989 100644 --- a/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html +++ b/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html @@ -9,7 +9,7 @@ Rust のプリミティブ型はどこからやって来るか | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html b/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html index 36ed4c1..a878638 100644 --- a/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html +++ b/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html @@ -9,7 +9,7 @@ 【Vim】 autocmd events の BufWrite/BufWritePre の違い | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html b/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html index e8deba6..ada0dbd 100644 --- a/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html +++ b/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html @@ -9,7 +9,7 @@ Vimで選択した行の順番を入れ替える | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2022-04-09/phperkaigi-2022-tokens/index.html b/public/posts/2022-04-09/phperkaigi-2022-tokens/index.html index 13f4e82..29e5f78 100644 --- a/public/posts/2022-04-09/phperkaigi-2022-tokens/index.html +++ b/public/posts/2022-04-09/phperkaigi-2022-tokens/index.html @@ -9,7 +9,7 @@ PHPerKaigi 2022 トークン問題の解説 | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2022-04-24/term-banner-write-tool-showing-banner-in-terminal/index.html b/public/posts/2022-04-24/term-banner-write-tool-showing-banner-in-terminal/index.html index 9e24629..f20db85 100644 --- a/public/posts/2022-04-24/term-banner-write-tool-showing-banner-in-terminal/index.html +++ b/public/posts/2022-04-24/term-banner-write-tool-showing-banner-in-terminal/index.html @@ -8,7 +8,7 @@ term-banner: ターミナルにバナーを表示するツールを書いた | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2022-05-01/phperkaigi-2022/index.html b/public/posts/2022-05-01/phperkaigi-2022/index.html index 60e0f56..b6c4797 100644 --- a/public/posts/2022-05-01/phperkaigi-2022/index.html +++ b/public/posts/2022-05-01/phperkaigi-2022/index.html @@ -9,7 +9,7 @@ PHPerKaigi 2022 | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2022-08-27/php-conference-okinawa-code-golf/index.html b/public/posts/2022-08-27/php-conference-okinawa-code-golf/index.html index f27dc0f..d1765f4 100644 --- a/public/posts/2022-08-27/php-conference-okinawa-code-golf/index.html +++ b/public/posts/2022-08-27/php-conference-okinawa-code-golf/index.html @@ -9,7 +9,7 @@ PHP カンファレンス沖縄で出題されたコードゴルフの問題を解いてみた | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2022-08-31/support-for-communty-is-employee-benefits/index.html b/public/posts/2022-08-31/support-for-communty-is-employee-benefits/index.html index 942b689..2fc47ad 100644 --- a/public/posts/2022-08-31/support-for-communty-is-employee-benefits/index.html +++ b/public/posts/2022-08-31/support-for-communty-is-employee-benefits/index.html @@ -8,7 +8,7 @@ 弊社の PHP Foundation への寄付に寄せて | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2022-09-29/write-fizzbuzz-in-php-2-letters-per-line/index.html b/public/posts/2022-09-29/write-fizzbuzz-in-php-2-letters-per-line/index.html index f233361..3d96761 100644 --- a/public/posts/2022-09-29/write-fizzbuzz-in-php-2-letters-per-line/index.html +++ b/public/posts/2022-09-29/write-fizzbuzz-in-php-2-letters-per-line/index.html @@ -9,7 +9,7 @@ 【PHP】 fizzbuzz を書く。1行あたり2文字で。 | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2022-10-23/phperkaigi-2023-unused-token-quiz-1/index.html b/public/posts/2022-10-23/phperkaigi-2023-unused-token-quiz-1/index.html index bb170c7..6769873 100644 --- a/public/posts/2022-10-23/phperkaigi-2023-unused-token-quiz-1/index.html +++ b/public/posts/2022-10-23/phperkaigi-2023-unused-token-quiz-1/index.html @@ -9,7 +9,7 @@ PHPerKaigi 2023: ボツになったトークン問題 その 1 | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2022-10-28/setup-server-for-this-site/index.html b/public/posts/2022-10-28/setup-server-for-this-site/index.html index 5dd20c2..8e1eea1 100644 --- a/public/posts/2022-10-28/setup-server-for-this-site/index.html +++ b/public/posts/2022-10-28/setup-server-for-this-site/index.html @@ -9,7 +9,7 @@ 【備忘録】 このサイト用の VPS をセットアップしたときのメモ | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2022-11-19/phperkaigi-2023-unused-token-quiz-2/index.html b/public/posts/2022-11-19/phperkaigi-2023-unused-token-quiz-2/index.html index ac66883..722602d 100644 --- a/public/posts/2022-11-19/phperkaigi-2023-unused-token-quiz-2/index.html +++ b/public/posts/2022-11-19/phperkaigi-2023-unused-token-quiz-2/index.html @@ -9,7 +9,7 @@ PHPerKaigi 2023: ボツになったトークン問題 その 2 | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2023-01-10/phperkaigi-2023-unused-token-quiz-3/index.html b/public/posts/2023-01-10/phperkaigi-2023-unused-token-quiz-3/index.html index 0f6cab0..e6dd41d 100644 --- a/public/posts/2023-01-10/phperkaigi-2023-unused-token-quiz-3/index.html +++ b/public/posts/2023-01-10/phperkaigi-2023-unused-token-quiz-3/index.html @@ -9,7 +9,7 @@ PHPerKaigi 2023: ボツになったトークン問題 その 3 | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/2023-03-10/rewrite-this-blog-generator/index.html b/public/posts/2023-03-10/rewrite-this-blog-generator/index.html index d0e82bd..8dea106 100644 --- a/public/posts/2023-03-10/rewrite-this-blog-generator/index.html +++ b/public/posts/2023-03-10/rewrite-this-blog-generator/index.html @@ -8,7 +8,7 @@ このブログのジェネレータを書き直した | REPL: Rest-Eat-Program Loop - + diff --git a/public/posts/index.html b/public/posts/index.html index e9b0ab2..71ac57c 100644 --- a/public/posts/index.html +++ b/public/posts/index.html @@ -8,7 +8,7 @@ 投稿一覧 | REPL: Rest-Eat-Program Loop - +
diff --git a/public/style.css b/public/style.css index a813c21..2376133 100644 --- a/public/style.css +++ b/public/style.css @@ -185,7 +185,8 @@ h1 { font-weight: bold; } -article.post-entry { +.post-entry { + min-width: calc(min(900px, 100vw - 2rem)); background-color: #f5f5f5; border-radius: 10px; padding: 1.5rem; diff --git a/public/tags/conference/index.html b/public/tags/conference/index.html index ac255da..7fff910 100644 --- a/public/tags/conference/index.html +++ b/public/tags/conference/index.html @@ -9,7 +9,7 @@ タグ「カンファレンス」一覧 | REPL: Rest-Eat-Program Loop - +
diff --git a/public/tags/cpp/index.html b/public/tags/cpp/index.html index fc83ba9..45cc1fd 100644 --- a/public/tags/cpp/index.html +++ b/public/tags/cpp/index.html @@ -9,7 +9,7 @@ タグ「C++」一覧 | REPL: Rest-Eat-Program Loop - +
diff --git a/public/tags/cpp17/index.html b/public/tags/cpp17/index.html index f170658..e591246 100644 --- a/public/tags/cpp17/index.html +++ b/public/tags/cpp17/index.html @@ -9,7 +9,7 @@ タグ「C++ 17」一覧 | REPL: Rest-Eat-Program Loop - +
diff --git a/public/tags/index.html b/public/tags/index.html new file mode 100644 index 0000000..59bed9d --- /dev/null +++ b/public/tags/index.html @@ -0,0 +1,122 @@ + + + + + + + + + + タグ一覧 | REPL: Rest-Eat-Program Loop + + + +
+ +
+
+ + + + + + + + + + + + + + +
+
+ © 2021 nsfisis +
+ + diff --git a/public/tags/note-to-self/index.html b/public/tags/note-to-self/index.html index 32ce8af..d21c8b2 100644 --- a/public/tags/note-to-self/index.html +++ b/public/tags/note-to-self/index.html @@ -9,7 +9,7 @@ タグ「備忘録」一覧 | REPL: Rest-Eat-Program Loop - +
diff --git a/public/tags/php/index.html b/public/tags/php/index.html index 32c4690..b32885c 100644 --- a/public/tags/php/index.html +++ b/public/tags/php/index.html @@ -9,7 +9,7 @@ タグ「PHP」一覧 | REPL: Rest-Eat-Program Loop - +
diff --git a/public/tags/phpcon/index.html b/public/tags/phpcon/index.html index 5af6ba0..8b026a9 100644 --- a/public/tags/phpcon/index.html +++ b/public/tags/phpcon/index.html @@ -9,7 +9,7 @@ タグ「PHP カンファレンス」一覧 | REPL: Rest-Eat-Program Loop - +
diff --git a/public/tags/phperkaigi/index.html b/public/tags/phperkaigi/index.html index 03d83ca..445c021 100644 --- a/public/tags/phperkaigi/index.html +++ b/public/tags/phperkaigi/index.html @@ -9,7 +9,7 @@ タグ「PHPerKaigi」一覧 | REPL: Rest-Eat-Program Loop - +
diff --git a/public/tags/python/index.html b/public/tags/python/index.html index f5f6b76..7276615 100644 --- a/public/tags/python/index.html +++ b/public/tags/python/index.html @@ -9,7 +9,7 @@ タグ「Python」一覧 | REPL: Rest-Eat-Program Loop - +
diff --git a/public/tags/python3/index.html b/public/tags/python3/index.html index 8c742da..fe40f47 100644 --- a/public/tags/python3/index.html +++ b/public/tags/python3/index.html @@ -9,7 +9,7 @@ タグ「Python 3」一覧 | REPL: Rest-Eat-Program Loop - +
diff --git a/public/tags/ruby/index.html b/public/tags/ruby/index.html index a5033b9..6347368 100644 --- a/public/tags/ruby/index.html +++ b/public/tags/ruby/index.html @@ -9,7 +9,7 @@ タグ「Ruby」一覧 | REPL: Rest-Eat-Program Loop - +
diff --git a/public/tags/ruby3/index.html b/public/tags/ruby3/index.html index 9793cfb..fbe3c24 100644 --- a/public/tags/ruby3/index.html +++ b/public/tags/ruby3/index.html @@ -9,7 +9,7 @@ タグ「Ruby 3」一覧 | REPL: Rest-Eat-Program Loop - +
diff --git a/public/tags/rust/index.html b/public/tags/rust/index.html index dd9ff39..de17103 100644 --- a/public/tags/rust/index.html +++ b/public/tags/rust/index.html @@ -9,7 +9,7 @@ タグ「Rust」一覧 | REPL: Rest-Eat-Program Loop - +
diff --git a/public/tags/vim/index.html b/public/tags/vim/index.html index d61d320..2d14052 100644 --- a/public/tags/vim/index.html +++ b/public/tags/vim/index.html @@ -9,7 +9,7 @@ タグ「Vim」一覧 | REPL: Rest-Eat-Program Loop - +
diff --git a/static/style.css b/static/style.css index a813c21..2376133 100644 --- a/static/style.css +++ b/static/style.css @@ -185,7 +185,8 @@ h1 { font-weight: bold; } -article.post-entry { +.post-entry { + min-width: calc(min(900px, 100vw - 2rem)); background-color: #f5f5f5; border-radius: 10px; padding: 1.5rem; -- cgit v1.2.3-70-g09d2