aboutsummaryrefslogtreecommitdiff
path: root/packages/astro/test/fixtures/content-layer-markdoc
diff options
context:
space:
mode:
Diffstat (limited to 'packages/astro/test/fixtures/content-layer-markdoc')
-rw-r--r--packages/astro/test/fixtures/content-layer-markdoc/astro.config.mjs8
-rw-r--r--packages/astro/test/fixtures/content-layer-markdoc/content/_nested.mdoc3
-rw-r--r--packages/astro/test/fixtures/content-layer-markdoc/content/blog/_counter.mdoc7
-rw-r--r--packages/astro/test/fixtures/content-layer-markdoc/content/blog/with-components.mdoc19
-rw-r--r--packages/astro/test/fixtures/content-layer-markdoc/markdoc.config.ts32
-rw-r--r--packages/astro/test/fixtures/content-layer-markdoc/package.json11
-rw-r--r--packages/astro/test/fixtures/content-layer-markdoc/src/components/Code.astro12
-rw-r--r--packages/astro/test/fixtures/content-layer-markdoc/src/components/Counter.tsx10
-rw-r--r--packages/astro/test/fixtures/content-layer-markdoc/src/components/CounterWrapper.astro5
-rw-r--r--packages/astro/test/fixtures/content-layer-markdoc/src/components/CustomMarquee.astro1
-rw-r--r--packages/astro/test/fixtures/content-layer-markdoc/src/components/DeeplyNested.astro5
-rw-r--r--packages/astro/test/fixtures/content-layer-markdoc/src/content.config.ts11
-rw-r--r--packages/astro/test/fixtures/content-layer-markdoc/src/pages/index.astro19
13 files changed, 143 insertions, 0 deletions
diff --git a/packages/astro/test/fixtures/content-layer-markdoc/astro.config.mjs b/packages/astro/test/fixtures/content-layer-markdoc/astro.config.mjs
new file mode 100644
index 000000000..db1faa249
--- /dev/null
+++ b/packages/astro/test/fixtures/content-layer-markdoc/astro.config.mjs
@@ -0,0 +1,8 @@
+import markdoc from '@astrojs/markdoc';
+import preact from '@astrojs/preact';
+import { defineConfig } from 'astro/config';
+
+// https://astro.build/config
+export default defineConfig({
+ integrations: [markdoc(), preact()]
+});
diff --git a/packages/astro/test/fixtures/content-layer-markdoc/content/_nested.mdoc b/packages/astro/test/fixtures/content-layer-markdoc/content/_nested.mdoc
new file mode 100644
index 000000000..68f529280
--- /dev/null
+++ b/packages/astro/test/fixtures/content-layer-markdoc/content/_nested.mdoc
@@ -0,0 +1,3 @@
+Render components from a deeply nested partial:
+
+{% deeply-nested /%}
diff --git a/packages/astro/test/fixtures/content-layer-markdoc/content/blog/_counter.mdoc b/packages/astro/test/fixtures/content-layer-markdoc/content/blog/_counter.mdoc
new file mode 100644
index 000000000..4a015695c
--- /dev/null
+++ b/packages/astro/test/fixtures/content-layer-markdoc/content/blog/_counter.mdoc
@@ -0,0 +1,7 @@
+# Hello from a partial!
+
+Render a component from a partial:
+
+{% counter /%}
+
+{% partial file="../_nested.mdoc" /%}
diff --git a/packages/astro/test/fixtures/content-layer-markdoc/content/blog/with-components.mdoc b/packages/astro/test/fixtures/content-layer-markdoc/content/blog/with-components.mdoc
new file mode 100644
index 000000000..eb7d20426
--- /dev/null
+++ b/packages/astro/test/fixtures/content-layer-markdoc/content/blog/with-components.mdoc
@@ -0,0 +1,19 @@
+---
+title: Post with components
+---
+
+## Post with components
+
+This uses a custom marquee component with a shortcode:
+
+{% marquee-element direction="right" %}
+I'm a marquee too!
+{% /marquee-element %}
+
+{% partial file="_counter.mdoc" /%}
+
+And a code component for code blocks:
+
+```js
+const isRenderedWithShiki = true;
+```
diff --git a/packages/astro/test/fixtures/content-layer-markdoc/markdoc.config.ts b/packages/astro/test/fixtures/content-layer-markdoc/markdoc.config.ts
new file mode 100644
index 000000000..6093ec593
--- /dev/null
+++ b/packages/astro/test/fixtures/content-layer-markdoc/markdoc.config.ts
@@ -0,0 +1,32 @@
+import { Markdoc, component, defineMarkdocConfig } from '@astrojs/markdoc/config';
+
+export default defineMarkdocConfig({
+ nodes: {
+ fence: {
+ render: component('./src/components/Code.astro'),
+ attributes: {
+ language: { type: String },
+ content: { type: String },
+ },
+ },
+ },
+ tags: {
+ 'marquee-element': {
+ render: component('./src/components/CustomMarquee.astro'),
+ attributes: {
+ direction: {
+ type: String,
+ default: 'left',
+ matches: ['left', 'right', 'up', 'down'],
+ errorLevel: 'critical',
+ },
+ },
+ },
+ counter: {
+ render: component('./src/components/CounterWrapper.astro'),
+ },
+ 'deeply-nested': {
+ render: component('./src/components/DeeplyNested.astro'),
+ },
+ },
+});
diff --git a/packages/astro/test/fixtures/content-layer-markdoc/package.json b/packages/astro/test/fixtures/content-layer-markdoc/package.json
new file mode 100644
index 000000000..2090ac577
--- /dev/null
+++ b/packages/astro/test/fixtures/content-layer-markdoc/package.json
@@ -0,0 +1,11 @@
+{
+ "name": "@test/content-layer-markdoc",
+ "version": "0.0.0",
+ "private": true,
+ "dependencies": {
+ "@astrojs/markdoc": "workspace:*",
+ "@astrojs/preact": "workspace:*",
+ "astro": "workspace:*",
+ "preact": "^10.26.4"
+ }
+} \ No newline at end of file
diff --git a/packages/astro/test/fixtures/content-layer-markdoc/src/components/Code.astro b/packages/astro/test/fixtures/content-layer-markdoc/src/components/Code.astro
new file mode 100644
index 000000000..18bf1399f
--- /dev/null
+++ b/packages/astro/test/fixtures/content-layer-markdoc/src/components/Code.astro
@@ -0,0 +1,12 @@
+---
+import { Code } from 'astro/components';
+
+type Props = {
+ content: string;
+ language: string;
+}
+
+const { content, language } = Astro.props as Props;
+---
+
+<Code lang={language} code={content} />
diff --git a/packages/astro/test/fixtures/content-layer-markdoc/src/components/Counter.tsx b/packages/astro/test/fixtures/content-layer-markdoc/src/components/Counter.tsx
new file mode 100644
index 000000000..f1e239718
--- /dev/null
+++ b/packages/astro/test/fixtures/content-layer-markdoc/src/components/Counter.tsx
@@ -0,0 +1,10 @@
+import { useState } from 'preact/hooks';
+
+export default function Counter() {
+ const [count, setCount] = useState(1);
+ return (
+ <button id="counter" onClick={() => setCount(count + 1)}>
+ {count}
+ </button>
+ );
+}
diff --git a/packages/astro/test/fixtures/content-layer-markdoc/src/components/CounterWrapper.astro b/packages/astro/test/fixtures/content-layer-markdoc/src/components/CounterWrapper.astro
new file mode 100644
index 000000000..e45ac6438
--- /dev/null
+++ b/packages/astro/test/fixtures/content-layer-markdoc/src/components/CounterWrapper.astro
@@ -0,0 +1,5 @@
+---
+import Counter from './Counter';
+---
+
+<Counter client:load />
diff --git a/packages/astro/test/fixtures/content-layer-markdoc/src/components/CustomMarquee.astro b/packages/astro/test/fixtures/content-layer-markdoc/src/components/CustomMarquee.astro
new file mode 100644
index 000000000..3108b9973
--- /dev/null
+++ b/packages/astro/test/fixtures/content-layer-markdoc/src/components/CustomMarquee.astro
@@ -0,0 +1 @@
+<marquee data-custom-marquee {...Astro.props}><slot /></marquee>
diff --git a/packages/astro/test/fixtures/content-layer-markdoc/src/components/DeeplyNested.astro b/packages/astro/test/fixtures/content-layer-markdoc/src/components/DeeplyNested.astro
new file mode 100644
index 000000000..eb23f675a
--- /dev/null
+++ b/packages/astro/test/fixtures/content-layer-markdoc/src/components/DeeplyNested.astro
@@ -0,0 +1,5 @@
+---
+
+---
+
+<p id="deeply-nested">Deeply nested partial</p>
diff --git a/packages/astro/test/fixtures/content-layer-markdoc/src/content.config.ts b/packages/astro/test/fixtures/content-layer-markdoc/src/content.config.ts
new file mode 100644
index 000000000..18ead9aa1
--- /dev/null
+++ b/packages/astro/test/fixtures/content-layer-markdoc/src/content.config.ts
@@ -0,0 +1,11 @@
+import { defineCollection } from 'astro:content';
+import { glob } from 'astro/loaders';
+
+const blog = defineCollection({
+ loader: glob({
+ pattern: '*.mdoc',
+ base: 'content/blog',
+ }),
+});
+
+export const collections = { blog };
diff --git a/packages/astro/test/fixtures/content-layer-markdoc/src/pages/index.astro b/packages/astro/test/fixtures/content-layer-markdoc/src/pages/index.astro
new file mode 100644
index 000000000..5c7747eef
--- /dev/null
+++ b/packages/astro/test/fixtures/content-layer-markdoc/src/pages/index.astro
@@ -0,0 +1,19 @@
+---
+import { getEntry, render } from "astro:content";
+
+const post = await getEntry('blog', 'with-components');
+const { Content } = await render(post);
+---
+
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Content</title>
+</head>
+<body>
+ <Content />
+</body>
+</html>