From b4b13960396ae7649189126d5fc741275f06b0d7 Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Fri, 10 Feb 2023 08:45:37 -0500 Subject: [PATCH] play: make sure md also works --- .../with-markdoc/src/content/blog/plain-md.md | 8 +++ .../with-markdoc/src/content/blog/test.mdoc | 4 +- examples/with-markdoc/src/pages/index.astro | 61 ++++++++++++------- 3 files changed, 48 insertions(+), 25 deletions(-) create mode 100644 examples/with-markdoc/src/content/blog/plain-md.md diff --git a/examples/with-markdoc/src/content/blog/plain-md.md b/examples/with-markdoc/src/content/blog/plain-md.md new file mode 100644 index 000000000..4a75a9f4b --- /dev/null +++ b/examples/with-markdoc/src/content/blog/plain-md.md @@ -0,0 +1,8 @@ +--- +title: Markdown +--- + +## Just markdown + +- working? +- yes. diff --git a/examples/with-markdoc/src/content/blog/test.mdoc b/examples/with-markdoc/src/content/blog/test.mdoc index 4b1c27546..849e2f269 100644 --- a/examples/with-markdoc/src/content/blog/test.mdoc +++ b/examples/with-markdoc/src/content/blog/test.mdoc @@ -1,8 +1,8 @@ --- -title: Example! +title: Markdoc --- -# Hey there +# Markdoc h2 Look at this table! Built-in to Markdoc, neat. diff --git a/examples/with-markdoc/src/pages/index.astro b/examples/with-markdoc/src/pages/index.astro index 5b8b67a9a..3a9ef6e83 100644 --- a/examples/with-markdoc/src/pages/index.astro +++ b/examples/with-markdoc/src/pages/index.astro @@ -2,14 +2,10 @@ import { Markdoc } from '@astrojs/markdoc'; import { Code } from 'astro/components'; import Marquee from '../components/Marquee.astro'; -import { getEntryBySlug } from 'astro:content'; +import { getCollection } from 'astro:content'; import RedP from '../components/RedP.astro'; -const mdocEntry = await getEntryBySlug('blog', 'test'); -const mdxEntry = await getEntryBySlug('blog', 'with-mdx'); -console.log(mdocEntry); -const { Content } = await mdocEntry.render(); -const { Content: MDXContent } = await mdxEntry.render(); +const entries = await getCollection('blog'); --- @@ -23,23 +19,42 @@ const { Content: MDXContent } = await mdxEntry.render();

Astro

- - + { + entries.map(async (entry) => { + const { Content } = await entry.render(); + if (entry.id.endsWith('mdoc')) { + return ( + +

{entry.data.title}

+ +
+
+ ); + } + return ( + <> +

{entry.data.title}

+ +
+ + ); + }) + }