From 652d1455b118d06fe58a4e882839ba91a775a399 Mon Sep 17 00:00:00 2001 From: kjirou Date: Tue, 3 Dec 2024 09:53:08 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=88=E3=83=83=E3=83=97=E3=83=9A=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=81=AE=E8=A8=98=E4=BA=8B=E4=B8=80=E8=A6=A7=E3=81=AE?= =?UTF-8?q?URL=E3=81=8B=E3=82=89".html"=E3=82=92=E5=89=8A=E9=99=A4?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 他に設定もないので、実質これで各記事のURLが ".html" なしと定義されることになる。 --- src/__tests__/index.test.ts | 2 +- src/page-generator.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/__tests__/index.test.ts b/src/__tests__/index.test.ts index 271b7ac..c0b873e 100644 --- a/src/__tests__/index.test.ts +++ b/src/__tests__/index.test.ts @@ -228,7 +228,7 @@ describe("executeCompile, executeCompileWithSettings", () => { ).not.toBe(-1); expect( dump["blog-publication/articles/20190101-0001.html"].indexOf( - '', + '', ), ).not.toBe(-1); expect( diff --git a/src/page-generator.ts b/src/page-generator.ts index 5435388..354b855 100644 --- a/src/page-generator.ts +++ b/src/page-generator.ts @@ -418,7 +418,9 @@ export interface ArticlePage { publicId: string; inputFilePath: string; outputFilePath: string; + // e.g. "/articles/20191231-0001" rootRelativePath: string; + // e.g. "https://{YOUR_DOMAIN}/articles/20191231-0001" permalink: string; ogpImageUrl: string; // "" means that it does not exist. ogpDescription: string; // "" means that it does not exist. @@ -521,8 +523,9 @@ export function preprocessArticlePages( const frontMatters = fillWithDefaultArticleFrontMatters(actualFrontMatters); const basePath = getPathnameWithoutTailingSlash(configs.blogUrl); - const rootRelativePath = `${basePath}/${RELATIVE_ARTICLES_DIR_PATH}/${frontMatters.publicId}.html`; - const permalink = `${configs.blogUrl}/${RELATIVE_ARTICLES_DIR_PATH}/${frontMatters.publicId}.html`; + // NOTE: ".html" は付与しない。GitHub Pages は、とても昔から ".html" の有無を考慮していない。また、npm package の serve も ".html" なしで動作する。 + const rootRelativePath = `${basePath}/${RELATIVE_ARTICLES_DIR_PATH}/${frontMatters.publicId}`; + const permalink = `${configs.blogUrl}/${RELATIVE_ARTICLES_DIR_PATH}/${frontMatters.publicId}`; let ogpImageUrl = ""; if (configs.ogp) {