Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
mashehu authored and ewels committed Mar 15, 2024
1 parent c70bcba commit 521beca
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 29 deletions.
49 changes: 22 additions & 27 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,29 @@ export default defineConfig({
name: "excerpt",
// transform: (desc) => desc.split(' ').length < 150 ? desc : `${desc.split(' ').slice(150).join(' ')}...`,
node: (node, i, parent) => {
// check if parent has a child that is an html comment with the text 'end of excerpt'
if (
parent?.children?.some(
(child) =>
(child.type === 'html' && child.value === "<!-- end-archive-description -->")
)
) {
const sibling = parent?.children[i + 1];
return (
(sibling?.type === 'html' && sibling?.value === "<!-- end-archive-description -->")
);
} else {
// return the first paragraph otherwise
// check if parent has a child that is an html comment with the text 'end of excerpt'
if (
parent?.children?.some(
(child) => child.type === "html" && child.value === "<!-- end-archive-description -->",
)
) {
const sibling = parent?.children[i + 1];
return sibling?.type === "html" && sibling?.value === "<!-- end-archive-description -->";
} else {
// return the first paragraph otherwise

// get the index of the first paragraph
const firstParagraphIndex = parent?.children.findIndex(
(child) => child.type === 'paragraph',
);
// 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;
},
// get the index of the first paragraph
const firstParagraphIndex = parent?.children.findIndex((child) => child.type === "paragraph");
// 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
4 changes: 2 additions & 2 deletions src/pages/blog/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const posts = (await getCollection("blog")).sort(
<hr />
<p class="blg-text">
{async () => {
const { remarkPluginFrontmatter } = await post.render();
return remarkPluginFrontmatter.excerpt;
const { remarkPluginFrontmatter } = await post.render();
return remarkPluginFrontmatter.excerpt;
}}
</p>
</section>
Expand Down

0 comments on commit 521beca

Please sign in to comment.