Skip to content

Commit

Permalink
Merge pull request #98 from kjirou/add-html-extension-option
Browse files Browse the repository at this point in the history
記事のURLから".html"を削除する
  • Loading branch information
kjirou authored Dec 3, 2024
2 parents fe55aa4 + 652d145 commit 42b0134
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 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
8 changes: 5 additions & 3 deletions src/page-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ function createRehypePlugins(params: {
};
documentOptions.css = params.cssUrls;
documentOptions.js = params.jsUrls;
const additionalHeadNodes = params.additionalHeadNodes;

const autolinkContent: HastscriptAst = {
type: "text",
Expand Down Expand Up @@ -419,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 @@ -522,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 42b0134

Please sign in to comment.