From d343a7262588050df2f4ad646769e5c6662c45e9 Mon Sep 17 00:00:00 2001 From: Nathan Jones Date: Fri, 19 Apr 2024 07:34:08 +1200 Subject: [PATCH 1/3] Pass "frontmatter" variable to content renderer Setting the "frontmatter" variable allows markdoc content to access the frontmatter like `{% $frontmatter.title %}` This pattern is documented in the Astro markdoc guide: https://docs.astro.build/en/guides/integrations-guide/markdoc/#access-frontmatter-from-your-markdoc-content --- packages/starlight/index.astro | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/starlight/index.astro b/packages/starlight/index.astro index 60f9016254..4e9c8bf26f 100644 --- a/packages/starlight/index.astro +++ b/packages/starlight/index.astro @@ -12,8 +12,9 @@ export async function getStaticPaths() { } type Props = InferGetStaticPropsType; -const { Content, headings } = await Astro.props.entry.render(); +const entry = Astro.props.entry; +const { Content, headings } = await entry.render(); const route = generateRouteData({ props: { ...Astro.props, headings }, url: Astro.url }); --- - + From 1a0554a1f8d2ec0d4bc50937a24e99e123dcd494 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Tue, 30 Apr 2024 16:38:05 +0200 Subject: [PATCH 2/3] code style tweak --- packages/starlight/index.astro | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/starlight/index.astro b/packages/starlight/index.astro index 4e9c8bf26f..74ba7b1c9b 100644 --- a/packages/starlight/index.astro +++ b/packages/starlight/index.astro @@ -12,9 +12,8 @@ export async function getStaticPaths() { } type Props = InferGetStaticPropsType; -const entry = Astro.props.entry; -const { Content, headings } = await entry.render(); +const { Content, headings } = await Astro.props.entry.render(); const route = generateRouteData({ props: { ...Astro.props, headings }, url: Astro.url }); --- - + From a8538c2b518c24f403b75e622f30fa6045b1e6c4 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Tue, 30 Apr 2024 16:40:20 +0200 Subject: [PATCH 3/3] Add changeset --- .changeset/tall-planets-destroy.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tall-planets-destroy.md diff --git a/.changeset/tall-planets-destroy.md b/.changeset/tall-planets-destroy.md new file mode 100644 index 0000000000..ecfe5d9648 --- /dev/null +++ b/.changeset/tall-planets-destroy.md @@ -0,0 +1,5 @@ +--- +'@astrojs/starlight': minor +--- + +Adds support for [accessing frontmatter data as a variable](https://docs.astro.build/en/guides/integrations-guide/markdoc/#access-frontmatter-from-your-markdoc-content) when using Markdoc