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)];
//TODO: Handle # Link
let slug = Transformer.parseFileNameFromPath(pageName);
if (slug.includes('#')) {
console.log(slug)
let canonicalSlug;
if (pageName.includes('#')) {
console.log(pageName)
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 = {
title: Transformer.parseFileNameFromPath(toFilePath(canonicalSlug)),