diff --git a/src/components/Article.tsx b/src/components/Article.tsx index 584a3f1..ca02874 100644 --- a/src/components/Article.tsx +++ b/src/components/Article.tsx @@ -5,6 +5,7 @@ import { HTMLProps } from "react"; import TableOfContentScrollEffect from "./TableOfContentScrollEffect"; import "highlight.js/styles/atom-one-dark.css"; import path from "path"; + export default function Article(params: HTMLProps & { markdown: string, markdownFilePath: string|null}) { const { markdown, className, markdownFilePath, ...restProps } = params; const headingsMapPoc = {}; @@ -78,10 +79,12 @@ export default function Article(params: HTMLProps & { markdown: return str; }; renderer.image = (href, title) => { - if (markdownFilePath === null) return ``; - const markdownDir = markdownFilePath.substring(0, markdownFilePath.lastIndexOf('/')); - const resolvedPath = path.join(path.relative('blog/', markdownDir),href); - return ``; + + if (markdownFilePath === null) return ``; + + const markdownDir = markdownFilePath.substring(0, markdownFilePath.lastIndexOf("/")); + const resolvedPath = path.join(path.relative("blog/", markdownDir),href); + return ``; }; return renderer; } diff --git a/src/utils/blog.ts b/src/utils/blog.ts index 35945f3..f0a0c96 100644 --- a/src/utils/blog.ts +++ b/src/utils/blog.ts @@ -54,6 +54,7 @@ export async function getBlogArticles(): Promise { if (attributes.authors !== undefined && !Array.isArray(attributes.authors)) { attributes.authors = [attributes.authors]; } + // blogPath relative to public const blogPath = path.relative(publicDir, articlePath).replace(/\\/g, "/");