Handle Internal link with hashtag('#')

This commit is contained in:
Tuan Cao 2022-04-17 20:22:50 +07:00
parent 40a947e2ea
commit 6f027aeb8e

View File

@ -134,12 +134,20 @@ export const Transformer = {
// let name = [Transformer.parseFileNameFromPath(pageName)]; // let name = [Transformer.parseFileNameFromPath(pageName)];
//TODO: Handle # Link let canonicalSlug;
let slug = Transformer.parseFileNameFromPath(pageName); if (pageName.includes('#')) {
if (slug.includes('#')) { console.log(pageName)
console.log(slug) const tempSlug = pageName.split('#')[0]
if (tempSlug.length === 0) {
// Meaning it in form of #Heading1 --> slug will be this file slug
canonicalSlug = toSlug(aFilePath)
} else {
canonicalSlug =Transformer.pageResolver(tempSlug)[0].split('#')[0]
} }
const canonicalSlug = Transformer.pageResolver(pageName)[0] } else {
canonicalSlug = Transformer.pageResolver(pageName)[0].split('#')[0]
}
const backLink = { const backLink = {
title: Transformer.parseFileNameFromPath(toFilePath(canonicalSlug)), title: Transformer.parseFileNameFromPath(toFilePath(canonicalSlug)),