From 0af2623f5aca74eb79fe43ad958c57f2bb9a30be Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Thu, 5 Sep 2024 17:23:12 +0800 Subject: [PATCH] fix: correct URL link conversion issue in markdown --- .idoc/.filesStat.json | 14 ++++++++++---- idoc.yml | 4 ++-- src/markdown/rehype-urls.ts | 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.idoc/.filesStat.json b/.idoc/.filesStat.json index f846d4cb..7327f170 100644 --- a/.idoc/.filesStat.json +++ b/.idoc/.filesStat.json @@ -120,10 +120,10 @@ "birthtime": "2022-04-10T14:24:24.105Z" }, "README.md": { - "atime": "2024-03-28T08:00:05.780Z", - "mtime": "2024-03-28T08:00:06.306Z", - "ctime": "2024-03-28T08:00:06.306Z", - "birthtime": "2024-03-25T14:35:19.388Z" + "atime": "2024-09-05T09:18:45.782Z", + "mtime": "2024-09-05T09:18:45.689Z", + "ctime": "2024-09-05T09:18:45.689Z", + "birthtime": "2024-06-23T02:42:03.100Z" }, "docs/introduce/README.zh.md": { "atime": "2024-08-28T20:34:18.097Z", @@ -136,5 +136,11 @@ "mtime": "2024-09-05T08:31:48.421Z", "ctime": "2024-09-05T08:31:48.421Z", "birthtime": "2024-09-05T07:04:21.856Z" + }, + "README.zh.md": { + "atime": "2024-09-05T09:17:06.366Z", + "mtime": "2024-09-05T09:17:05.121Z", + "ctime": "2024-09-05T09:17:05.121Z", + "birthtime": "2024-09-05T09:07:56.196Z" } } diff --git a/idoc.yml b/idoc.yml index bad18e01..3b4d8199 100644 --- a/idoc.yml +++ b/idoc.yml @@ -104,8 +104,8 @@ footer: | ## Add Markdown files that are not in the specified directory. # ----------------------- -# sideEffectFiles: -# - README.zh.md +sideEffectFiles: + - README.zh.md giscus: diff --git a/src/markdown/rehype-urls.ts b/src/markdown/rehype-urls.ts index a00c314a..3a4940bb 100644 --- a/src/markdown/rehype-urls.ts +++ b/src/markdown/rehype-urls.ts @@ -17,11 +17,11 @@ export default function rehypeUrls(node: Root | RootContent, fromPath: string) { .join('/') .replace(/([^\.\/\\]+)\.(md|markdown)/gi, '$1.html'); } - if (/\/(README)\.?(\w+)?\.(md|markdown)$/i.test(href)) { + if (/(README)\.?(\w+)?\.(md|markdown)$/i.test(href)) { node.properties.href = href .toLocaleLowerCase() - .replace(/\/(README)\.?(\w+)?\.(md|markdown)$/i, (match, p1, p2) => { - return `/index${p2 ? '.' + p2 : ''}.html`; + .replace(/(README)\.?(\w+)?\.(md|markdown)$/i, (match, p1, p2) => { + return `index${p2 ? '.' + p2 : ''}.html`; }); } else { node.properties.href = href.replace(/([^\.\/\\]+)\.(md|markdown)/gi, '$1.html');