summaryrefslogtreecommitdiff
path: root/examples/with-markdoc
diff options
context:
space:
mode:
Diffstat (limited to 'examples/with-markdoc')
-rw-r--r--examples/with-markdoc/README.md15
-rw-r--r--examples/with-markdoc/astro.config.mjs14
-rw-r--r--examples/with-markdoc/markdoc.config.mjs14
-rw-r--r--examples/with-markdoc/package.json3
-rw-r--r--examples/with-markdoc/src/components/DocsContent.astro32
-rw-r--r--examples/with-markdoc/src/pages/index.astro19
6 files changed, 36 insertions, 61 deletions
diff --git a/examples/with-markdoc/README.md b/examples/with-markdoc/README.md
index 62f7cbfc8..b5adbf27b 100644
--- a/examples/with-markdoc/README.md
+++ b/examples/with-markdoc/README.md
@@ -23,23 +23,20 @@ Inside of your Astro project, you'll see the following folders and files:
└── docs/
│ └── intro.mdoc
| └── config.ts
-│ └── components/
-| ├── Aside.astro
-│ └── DocsContent.astro
-│ └── layouts/
-│ └── Layout.astro
-│ └── pages/
-│ └── index.astro
+│ └── components/Aside.astro
+│ └── layouts/Layout.astro
+│ └── pages/index.astro
| └── env.d.ts
├── astro.config.mjs
+├── markdoc.config.mjs
├── README.md
├── package.json
└── tsconfig.json
```
-Markdoc (`.mdoc`) files can be used in content collections to author your Markdown content alongside Astro and server-rendered UI framework components (React, Vue, Svelte, and more). See `src/content/docs/` for an example file.
+Markdoc (`.mdoc`) files can be used in content collections. See `src/content/docs/` for an example file.
-You can also apply Astro components and server-rendered UI components (React, Vue, Svelte, etc) to your Markdoc files. See `src/content/DocsContent.astro` for an example.
+You can also render Astro components from your Markdoc files using [tags](https://markdoc.dev/docs/tags). See the `markdoc.config.mjs` file for an example configuration.
## 🧞 Commands
diff --git a/examples/with-markdoc/astro.config.mjs b/examples/with-markdoc/astro.config.mjs
index d88ed2098..29d846359 100644
--- a/examples/with-markdoc/astro.config.mjs
+++ b/examples/with-markdoc/astro.config.mjs
@@ -3,17 +3,5 @@ import markdoc from '@astrojs/markdoc';
// https://astro.build/config
export default defineConfig({
- integrations: [
- markdoc({
- tags: {
- aside: {
- render: 'Aside',
- attributes: {
- type: { type: String },
- title: { type: String },
- },
- },
- },
- }),
- ],
+ integrations: [markdoc()],
});
diff --git a/examples/with-markdoc/markdoc.config.mjs b/examples/with-markdoc/markdoc.config.mjs
new file mode 100644
index 000000000..0ae63d4ee
--- /dev/null
+++ b/examples/with-markdoc/markdoc.config.mjs
@@ -0,0 +1,14 @@
+import { defineMarkdocConfig } from '@astrojs/markdoc/config';
+import Aside from './src/components/Aside.astro';
+
+export default defineMarkdocConfig({
+ tags: {
+ aside: {
+ render: Aside,
+ attributes: {
+ type: { type: String },
+ title: { type: String },
+ },
+ },
+ },
+});
diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json
index 9ca562fa3..f31392840 100644
--- a/examples/with-markdoc/package.json
+++ b/examples/with-markdoc/package.json
@@ -12,6 +12,7 @@
},
"dependencies": {
"@astrojs/markdoc": "^0.0.5",
- "astro": "^2.1.7"
+ "astro": "^2.1.7",
+ "kleur": "^4.1.5"
}
}
diff --git a/examples/with-markdoc/src/components/DocsContent.astro b/examples/with-markdoc/src/components/DocsContent.astro
deleted file mode 100644
index 162c1fc6d..000000000
--- a/examples/with-markdoc/src/components/DocsContent.astro
+++ /dev/null
@@ -1,32 +0,0 @@
----
-import Aside from './Aside.astro';
-import type { CollectionEntry } from 'astro:content';
-
-type Props = {
- entry: CollectionEntry<'docs'>;
-};
-
-const { entry } = Astro.props;
-const { Content } = await entry.render();
----
-
-<Content
- components={{
- // Pass a mapping from the component name
- // To an Astro or UI component import
- // See your `astro.config.mjs` for
- // for the Markdoc tag mapping
- Aside,
- }}
-/>
-
-<style is:global>
- table {
- margin-block: 2rem;
- margin-inline: auto;
- }
- table td {
- padding-block: 0.3rem;
- padding-inline: 0.5rem;
- }
-</style>
diff --git a/examples/with-markdoc/src/pages/index.astro b/examples/with-markdoc/src/pages/index.astro
index 01412cce1..7efcbeda8 100644
--- a/examples/with-markdoc/src/pages/index.astro
+++ b/examples/with-markdoc/src/pages/index.astro
@@ -1,18 +1,25 @@
---
import { getEntryBySlug } from 'astro:content';
-import DocsContent from '../components/DocsContent.astro';
import Layout from '../layouts/Layout.astro';
const intro = await getEntryBySlug('docs', 'intro');
+const { Content } = await intro.render();
---
<Layout title={intro.data.title}>
<main>
<h1>{intro.data.title}</h1>
- <!-- `DocsContent` is a thin wrapper around -->
- <!-- the `Content` component provided by Content Collections, -->
- <!-- with added configuration for components. -->
- <!-- This allows you to share global components wherever you render your Markdoc. -->
- <DocsContent entry={intro} />
+ <Content variables={{ revealSecret: true }} />
</main>
</Layout>
+
+<style is:global>
+ table {
+ margin-block: 2rem;
+ margin-inline: auto;
+ }
+ table td {
+ padding-block: 0.3rem;
+ padding-inline: 0.5rem;
+ }
+</style>