Skip to content

Commit

Permalink
fix: correct URL link conversion issue in markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Sep 5, 2024
1 parent 37a8ae5 commit 0af2623
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
14 changes: 10 additions & 4 deletions .idoc/.filesStat.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
4 changes: 2 additions & 2 deletions idoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ footer: |
## Add Markdown files that are not in the specified directory.
# -----------------------
# sideEffectFiles:
# - README.zh.md
sideEffectFiles:
- README.zh.md


giscus:
Expand Down
6 changes: 3 additions & 3 deletions src/markdown/rehype-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 0af2623

Please sign in to comment.