Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint fix #32

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/components/Article.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLDivElement> & { markdown: string, markdownFilePath: string|null}) {
const { markdown, className, markdownFilePath, ...restProps } = params;
const headingsMapPoc = {};
Expand Down Expand Up @@ -78,10 +79,12 @@ export default function Article(params: HTMLProps<HTMLDivElement> & { markdown:
return str;
};
renderer.image = (href, title) => {
if (markdownFilePath === null) return `<img src="${href}" title="${title || ''}" />`;
const markdownDir = markdownFilePath.substring(0, markdownFilePath.lastIndexOf('/'));
const resolvedPath = path.join(path.relative('blog/', markdownDir),href);
return `<img src="${resolvedPath}" title="${title || ''}" />`;

if (markdownFilePath === null) return `<img src="${href}" title="${title || ""}" />`;

const markdownDir = markdownFilePath.substring(0, markdownFilePath.lastIndexOf("/"));
const resolvedPath = path.join(path.relative("blog/", markdownDir),href);
return `<img src="${resolvedPath}" title="${title || ""}" />`;
};
return renderer;
}
Expand Down
1 change: 1 addition & 0 deletions src/utils/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export async function getBlogArticles(): Promise<BlogArticle[]> {
if (attributes.authors !== undefined && !Array.isArray(attributes.authors)) {
attributes.authors = [attributes.authors];
}

// blogPath relative to public
const blogPath = path.relative(publicDir, articlePath).replace(/\\/g, "/");

Expand Down
Loading