diff --git a/plugin/contents_conversion/convertLinks.ts b/plugin/contents_conversion/convertLinks.ts index e6608581..5fbeb50b 100644 --- a/plugin/contents_conversion/convertLinks.ts +++ b/plugin/contents_conversion/convertLinks.ts @@ -73,13 +73,15 @@ export function convertWikilinks( } fileContent = fileContent.replace(wikiMatch, linkCreator); } else if (!fileName.startsWith('http')) { + const altMatch = wikiMatch.match(/(\|).*(]])/); const altCreator = fileName.split('/'); const altLink = creatorAltLink(altMatch, altCreator, fileName.split('.').at(-1), fileName); const removeEmbed = !isAttachment(fileName.trim()) && conditionConvert.removeEmbed && isEmbedBool; if (convertWikilink){ - linkCreator = `${isEmbed}[${altLink}](${encodeURI(fileName.trim()) + '.md'})`; + const markdownName = !isAttachment(fileName.trim()) ? fileName.trim() + '.md' : fileName.trim(); + linkCreator = `${isEmbed}[${altLink}](${encodeURI(markdownName)})`; } if (!isAttachment(fileName.trim()) && !convertLinks && !isEmbedBool) { linkCreator = altLink;