Skip to content

Commit

Permalink
トップページの記事一覧のURLから".html"を削除する
Browse files Browse the repository at this point in the history
他に設定もないので、実質これで各記事のURLが ".html" なしと定義されることになる。
  • Loading branch information
kjirou committed Dec 3, 2024
1 parent 746efaa commit 652d145
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ describe("executeCompile, executeCompileWithSettings", () => {
).not.toBe(-1);
expect(
dump["blog-publication/articles/20190101-0001.html"].indexOf(
'<meta property="og:url" content="https://example.com/bar/articles/20190101-0001.html">',
'<meta property="og:url" content="https://example.com/bar/articles/20190101-0001">',
),
).not.toBe(-1);
expect(
Expand Down
7 changes: 5 additions & 2 deletions src/page-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 652d145

Please sign in to comment.