Skip to content

Commit

Permalink
Fix types in remarkLocalImages
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallku committed Jan 16, 2025
1 parent b65f19f commit 1bfb39e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions apps/blog/src/plugins/lib/remarkLocalImages.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { mkdirSync, copyFileSync } from "node:fs";
import { join, dirname, relative } from "node:path";
import { visit } from "unist-util-visit";
import type { Root } from "mdast";
import { POSTS_DIRECTORY, PUBLIC_DIRECTORY } from "#constants";

export default function remarkLocalImages({ slug }: { slug: string }) {
const postsDir = POSTS_DIRECTORY;
const publicDir = PUBLIC_DIRECTORY;

return (tree: any, file: any) => {
visit(tree, "image", (node: any) => {
return (tree: Root) => {
visit(tree, "image", (node) => {
const imageUrl = node.url || "";

// Only handle local images (e.g., './images/foo.png')
if (!imageUrl.startsWith("./")) return;
if (!imageUrl.startsWith("./")) {
return;
}

// Absolute path to the MDX file
const mdxFilePath = join(postsDir, slug, "index.mdx");
Expand Down

0 comments on commit 1bfb39e

Please sign in to comment.