Skip to content

Commit

Permalink
Merge of #6165
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Mar 5, 2025
2 parents 219ad45 + b5d51a7 commit 6ef4d2e
Show file tree
Hide file tree
Showing 12 changed files with 430 additions and 225 deletions.
3 changes: 2 additions & 1 deletion astro.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import mdx from '@astrojs/mdx';
import { defineConfig } from 'astro/config';
import { RemarkPlugin } from '@astrojs/markdown-remark';
import AutoImport from 'astro-auto-import';
import { astroExpressiveCode } from 'astro-expressive-code';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
Expand Down Expand Up @@ -68,7 +69,7 @@ export default defineConfig({
remarkGraphvizPlugin(),
remarkAlgolia(),
[
remarkSmartypants,
remarkSmartypants as RemarkPlugin,
{
dashes: false,
},
Expand Down
4 changes: 2 additions & 2 deletions integrations/astro-asides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function remarkAsides(): unified.Plugin<[], mdast.Root> {
// title prop, and remove the paragraph from children.
let title: string | undefined;
remove(node, (child) => {
if (child.data?.directiveLabel) {
if ((child.data as { directiveLabel?: string })?.directiveLabel) {
if ('children' in child && 'value' in child.children[0]) {
title = child.children[0].value;
}
Expand All @@ -59,7 +59,7 @@ function remarkAsides(): unified.Plugin<[], mdast.Root> {
parent.children[index] = makeComponentNode(
AsideTagname,
{ attributes: { type, title } },
...node.children
...node.children as mdast.BlockContent[]
);
});
};
Expand Down
5 changes: 2 additions & 3 deletions integrations/astro-youtube-embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ export const youtubeAutoImport: Record<string, [string, string][]> = {
function remarkYoutubeEmbed(): unified.Plugin<[], mdast.Root> {
const transformer: unified.Transformer<mdast.Root> = (tree) => {
visit(tree, (node, index, parent) => {
// @ts-expect-error Possibly infinite type instantiation we can’t do anything about.
if (!parent || index === null || node.type !== 'leafDirective' || node.name !== 'youtube')
return;
let title: string | undefined;

remove(node, (child) => {
if (child.data?.directiveLabel) {
if ((child.data as { directiveLabel?: string })?.directiveLabel) {
if ('children' in child && 'value' in child.children[0]) {
title = child.children[0].value;
}
Expand All @@ -40,7 +39,7 @@ function remarkYoutubeEmbed(): unified.Plugin<[], mdast.Root> {
parent.children[index] = makeComponentNode(
YoutubeTagname,
{ attributes: { title, video: node.attributes.v } },
...node.children
...node.children as mdast.BlockContent[]
);
});
};
Expand Down
Loading

0 comments on commit 6ef4d2e

Please sign in to comment.