Skip to content

Commit

Permalink
remove filter and handle images as first paragraph
Browse files Browse the repository at this point in the history
  • Loading branch information
mashehu committed Mar 15, 2024
1 parent 521beca commit 7419ba4
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,13 @@ export default defineConfig({
} else {
// return the first paragraph otherwise

// get the index of the first paragraph
const firstParagraphIndex = parent?.children.findIndex((child) => child.type === "paragraph");
// get the index of the first paragraph and check that it doesn't start with an image
const firstParagraphIndex = parent?.children.findIndex((child) => child.type === "paragraph" && !child.children[0].value?.startsWith('<img '));

// if the node is the first paragraph, return true
return i === firstParagraphIndex;
}
},
filter: (options, { path }) => {
if (!path.startsWith("/src/content/blog")) {
return false; // Return falsey value to skip
}
return options;
},
},
],
],
Expand Down

0 comments on commit 7419ba4

Please sign in to comment.