@astrojs/markdoc 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -5
- package/CHANGELOG.md +18 -0
- package/components/TreeNode.ts +9 -1
- package/package.json +5 -5
- package/test/fixtures/content-collections/node_modules/.bin/astro +2 -2
- package/test/fixtures/entry-prop/node_modules/.bin/astro +2 -2
- package/test/fixtures/image-assets/node_modules/.bin/astro +2 -2
- package/test/fixtures/render-null/astro.config.mjs +7 -0
- package/test/fixtures/render-null/markdoc.config.mjs +26 -0
- package/test/fixtures/render-null/node_modules/.bin/astro +17 -0
- package/test/fixtures/render-null/package.json +9 -0
- package/test/fixtures/render-null/src/content/blog/render-null.mdoc +7 -0
- package/test/fixtures/render-null/src/pages/index.astro +19 -0
- package/test/fixtures/render-simple/node_modules/.bin/astro +2 -2
- package/test/fixtures/render-with-components/node_modules/.bin/astro +2 -2
- package/test/fixtures/render-with-components/package.json +1 -1
- package/test/fixtures/render-with-config/node_modules/.bin/astro +2 -2
- package/test/render.test.js +80 -54
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
[36m@astrojs/markdoc:build: [0m
|
|
1
|
+
|
|
2
|
+
> @astrojs/markdoc@0.1.2 build /home/runner/work/astro/astro/packages/integrations/markdoc
|
|
3
|
+
> astro-scripts build "src/**/*.ts" && tsc
|
|
4
|
+
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @astrojs/markdoc
|
|
2
2
|
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#6932](https://github.com/withastro/astro/pull/6932) [`49514e4ce`](https://github.com/withastro/astro/commit/49514e4ce40fedb39bf7decd2c296258efbdafc7) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade shiki to v0.14.1. This updates the shiki theme colors and adds the theme name to the `pre` tag, e.g. `<pre class="astro-code github-dark">`.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`818252acd`](https://github.com/withastro/astro/commit/818252acda3c00499cea51ffa0f26d4c2ccd3a02), [`80e3d4d3d`](https://github.com/withastro/astro/commit/80e3d4d3d0f7719d8eae5435bba3805503057511), [`3326492b9`](https://github.com/withastro/astro/commit/3326492b94f76ed2b0154dd9b9a1a9eb883c1e31), [`cac4a321e`](https://github.com/withastro/astro/commit/cac4a321e814fb805eb0e3ced469e25261a50885), [`831b67cdb`](https://github.com/withastro/astro/commit/831b67cdb8250f93f66e3b171fab024652bf80f2), [`49514e4ce`](https://github.com/withastro/astro/commit/49514e4ce40fedb39bf7decd2c296258efbdafc7), [`0883fd487`](https://github.com/withastro/astro/commit/0883fd4875548a613df122f0b87a1ca8b7a7cf7d)]:
|
|
10
|
+
- astro@2.4.0
|
|
11
|
+
|
|
12
|
+
## 0.1.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#6723](https://github.com/withastro/astro/pull/6723) [`73fcc7627`](https://github.com/withastro/astro/commit/73fcc7627e27a001d3ed2f4d046999d91f1aef85) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Fix: when using `render: null` in your config, content is now rendered without a wrapper element.
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`489dd8d69`](https://github.com/withastro/astro/commit/489dd8d69cdd9d7c243cf8bec96051a914984b9c), [`a1a4f45b5`](https://github.com/withastro/astro/commit/a1a4f45b51a80215fa7598da83bd0d9c5acd20d2), [`a1108e037`](https://github.com/withastro/astro/commit/a1108e037115cdb67d03505286c7d3a4fc2a1ff5), [`8b88e4cf1`](https://github.com/withastro/astro/commit/8b88e4cf15c8bea7942b3985380164e0edf7250b), [`d54cbe413`](https://github.com/withastro/astro/commit/d54cbe41349e55f8544212ad9320705f07325920), [`4c347ab51`](https://github.com/withastro/astro/commit/4c347ab51e46f2319d614f8577fe502e3dc816e2), [`ff0430786`](https://github.com/withastro/astro/commit/ff043078630e678348ae4f4757b3015b3b862c16), [`2f2e572e9`](https://github.com/withastro/astro/commit/2f2e572e937fd25451bbc78a05d55b7caa1ca3ec), [`7116c021a`](https://github.com/withastro/astro/commit/7116c021a39eac15a6e1264dfbd11bef0f5d618a)]:
|
|
19
|
+
- astro@2.2.0
|
|
20
|
+
|
|
3
21
|
## 0.1.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/components/TreeNode.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AstroInstance } from 'astro';
|
|
2
|
+
import { Fragment } from 'astro/jsx-runtime';
|
|
2
3
|
import type { RenderableTreeNode } from '@markdoc/markdoc';
|
|
3
4
|
import Markdoc from '@markdoc/markdoc';
|
|
4
5
|
import { createComponent, renderComponent, render } from 'astro/runtime/server/index.js';
|
|
@@ -44,9 +45,16 @@ export const ComponentNode = createComponent({
|
|
|
44
45
|
propagation: 'none',
|
|
45
46
|
});
|
|
46
47
|
|
|
47
|
-
export function createTreeNode(node: RenderableTreeNode): TreeNode {
|
|
48
|
+
export function createTreeNode(node: RenderableTreeNode | RenderableTreeNode[]): TreeNode {
|
|
48
49
|
if (typeof node === 'string' || typeof node === 'number') {
|
|
49
50
|
return { type: 'text', content: String(node) };
|
|
51
|
+
} else if (Array.isArray(node)) {
|
|
52
|
+
return {
|
|
53
|
+
type: 'component',
|
|
54
|
+
component: Fragment,
|
|
55
|
+
props: {},
|
|
56
|
+
children: node.map((child) => createTreeNode(child)),
|
|
57
|
+
};
|
|
50
58
|
} else if (node === null || typeof node !== 'object' || !Markdoc.Tag.isTag(node)) {
|
|
51
59
|
return { type: 'text', content: '' };
|
|
52
60
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/markdoc",
|
|
3
3
|
"description": "Add support for Markdoc pages in your Astro site",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -34,20 +34,20 @@
|
|
|
34
34
|
"zod": "^3.17.3"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"astro": "^2.
|
|
37
|
+
"astro": "^2.4.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/chai": "^4.3.1",
|
|
41
41
|
"@types/html-escaper": "^3.0.0",
|
|
42
42
|
"@types/mocha": "^9.1.1",
|
|
43
|
-
"astro": "2.1.8",
|
|
44
|
-
"astro-scripts": "0.0.14",
|
|
45
43
|
"chai": "^4.3.6",
|
|
46
44
|
"devalue": "^4.2.0",
|
|
47
45
|
"linkedom": "^0.14.12",
|
|
48
46
|
"mocha": "^9.2.2",
|
|
49
47
|
"rollup": "^3.20.1",
|
|
50
|
-
"vite": "^4.
|
|
48
|
+
"vite": "^4.3.1",
|
|
49
|
+
"astro": "2.4.0",
|
|
50
|
+
"astro-scripts": "0.0.14"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": ">=16.12.0"
|
|
@@ -6,9 +6,9 @@ case `uname` in
|
|
|
6
6
|
esac
|
|
7
7
|
|
|
8
8
|
if [ -z "$NODE_PATH" ]; then
|
|
9
|
-
export NODE_PATH="/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
|
|
9
|
+
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
|
|
10
10
|
else
|
|
11
|
-
export NODE_PATH="
|
|
11
|
+
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
12
|
fi
|
|
13
13
|
if [ -x "$basedir/node" ]; then
|
|
14
14
|
exec "$basedir/node" "$basedir/../../../../../../../astro/astro.js" "$@"
|
|
@@ -6,9 +6,9 @@ case `uname` in
|
|
|
6
6
|
esac
|
|
7
7
|
|
|
8
8
|
if [ -z "$NODE_PATH" ]; then
|
|
9
|
-
export NODE_PATH="/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
|
|
9
|
+
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
|
|
10
10
|
else
|
|
11
|
-
export NODE_PATH="
|
|
11
|
+
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
12
|
fi
|
|
13
13
|
if [ -x "$basedir/node" ]; then
|
|
14
14
|
exec "$basedir/node" "$basedir/../../../../../../../astro/astro.js" "$@"
|
|
@@ -6,9 +6,9 @@ case `uname` in
|
|
|
6
6
|
esac
|
|
7
7
|
|
|
8
8
|
if [ -z "$NODE_PATH" ]; then
|
|
9
|
-
export NODE_PATH="/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
|
|
9
|
+
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
|
|
10
10
|
else
|
|
11
|
-
export NODE_PATH="
|
|
11
|
+
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
12
|
fi
|
|
13
13
|
if [ -x "$basedir/node" ]; then
|
|
14
14
|
exec "$basedir/node" "$basedir/../../../../../../../astro/astro.js" "$@"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineMarkdocConfig } from '@astrojs/markdoc/config';
|
|
2
|
+
|
|
3
|
+
export default defineMarkdocConfig({
|
|
4
|
+
nodes: {
|
|
5
|
+
document: {
|
|
6
|
+
render: null,
|
|
7
|
+
|
|
8
|
+
// Defaults from `Markdoc.nodes.document`
|
|
9
|
+
children: [
|
|
10
|
+
'heading',
|
|
11
|
+
'paragraph',
|
|
12
|
+
'image',
|
|
13
|
+
'table',
|
|
14
|
+
'tag',
|
|
15
|
+
'fence',
|
|
16
|
+
'blockquote',
|
|
17
|
+
'comment',
|
|
18
|
+
'list',
|
|
19
|
+
'hr',
|
|
20
|
+
],
|
|
21
|
+
attributes: {
|
|
22
|
+
frontmatter: { render: false },
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../../../../../../../astro/astro.js" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../../../../../../../astro/astro.js" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { getEntryBySlug } from "astro:content";
|
|
3
|
+
|
|
4
|
+
const post = await getEntryBySlug('blog', 'render-null');
|
|
5
|
+
const { Content } = await post.render();
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
<!DOCTYPE html>
|
|
9
|
+
<html lang="en">
|
|
10
|
+
<head>
|
|
11
|
+
<meta charset="UTF-8">
|
|
12
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
13
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
14
|
+
<title>Content</title>
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<Content />
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
|
@@ -6,9 +6,9 @@ case `uname` in
|
|
|
6
6
|
esac
|
|
7
7
|
|
|
8
8
|
if [ -z "$NODE_PATH" ]; then
|
|
9
|
-
export NODE_PATH="/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
|
|
9
|
+
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
|
|
10
10
|
else
|
|
11
|
-
export NODE_PATH="
|
|
11
|
+
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
12
|
fi
|
|
13
13
|
if [ -x "$basedir/node" ]; then
|
|
14
14
|
exec "$basedir/node" "$basedir/../../../../../../../astro/astro.js" "$@"
|
|
@@ -6,9 +6,9 @@ case `uname` in
|
|
|
6
6
|
esac
|
|
7
7
|
|
|
8
8
|
if [ -z "$NODE_PATH" ]; then
|
|
9
|
-
export NODE_PATH="/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
|
|
9
|
+
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
|
|
10
10
|
else
|
|
11
|
-
export NODE_PATH="
|
|
11
|
+
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
12
|
fi
|
|
13
13
|
if [ -x "$basedir/node" ]; then
|
|
14
14
|
exec "$basedir/node" "$basedir/../../../../../../../astro/astro.js" "$@"
|
|
@@ -6,9 +6,9 @@ case `uname` in
|
|
|
6
6
|
esac
|
|
7
7
|
|
|
8
8
|
if [ -z "$NODE_PATH" ]; then
|
|
9
|
-
export NODE_PATH="/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
|
|
9
|
+
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
|
|
10
10
|
else
|
|
11
|
-
export NODE_PATH="
|
|
11
|
+
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
12
|
fi
|
|
13
13
|
if [ -x "$basedir/node" ]; then
|
|
14
14
|
exec "$basedir/node" "$basedir/../../../../../../../astro/astro.js" "$@"
|
package/test/render.test.js
CHANGED
|
@@ -16,11 +16,8 @@ describe('Markdoc - render', () => {
|
|
|
16
16
|
|
|
17
17
|
const res = await fixture.fetch('/');
|
|
18
18
|
const html = await res.text();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
expect(h2.textContent).to.equal('Simple post');
|
|
22
|
-
const p = document.querySelector('p');
|
|
23
|
-
expect(p.textContent).to.equal('This is a simple Markdoc post.');
|
|
19
|
+
|
|
20
|
+
renderSimpleChecks(html);
|
|
24
21
|
|
|
25
22
|
await server.stop();
|
|
26
23
|
});
|
|
@@ -31,17 +28,8 @@ describe('Markdoc - render', () => {
|
|
|
31
28
|
|
|
32
29
|
const res = await fixture.fetch('/');
|
|
33
30
|
const html = await res.text();
|
|
34
|
-
const { document } = parseHTML(html);
|
|
35
|
-
const h2 = document.querySelector('h2');
|
|
36
|
-
expect(h2.textContent).to.equal('Post with config');
|
|
37
|
-
const textContent = html;
|
|
38
|
-
|
|
39
|
-
expect(textContent).to.not.include('Hello');
|
|
40
|
-
expect(textContent).to.include('Hola');
|
|
41
|
-
expect(textContent).to.include(`Konnichiwa`);
|
|
42
31
|
|
|
43
|
-
|
|
44
|
-
expect(runtimeVariable?.textContent?.trim()).to.equal('working!');
|
|
32
|
+
renderConfigChecks(html);
|
|
45
33
|
|
|
46
34
|
await server.stop();
|
|
47
35
|
});
|
|
@@ -52,19 +40,20 @@ describe('Markdoc - render', () => {
|
|
|
52
40
|
|
|
53
41
|
const res = await fixture.fetch('/');
|
|
54
42
|
const html = await res.text();
|
|
55
|
-
const { document } = parseHTML(html);
|
|
56
|
-
const h2 = document.querySelector('h2');
|
|
57
|
-
expect(h2.textContent).to.equal('Post with components');
|
|
58
43
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
44
|
+
renderComponentsChecks(html);
|
|
45
|
+
|
|
46
|
+
await server.stop();
|
|
47
|
+
});
|
|
63
48
|
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
49
|
+
it('renders content - with `render: null` in document', async () => {
|
|
50
|
+
const fixture = await getFixture('render-null');
|
|
51
|
+
const server = await fixture.startDevServer();
|
|
52
|
+
|
|
53
|
+
const res = await fixture.fetch('/');
|
|
54
|
+
const html = await res.text();
|
|
55
|
+
|
|
56
|
+
renderNullChecks(html);
|
|
68
57
|
|
|
69
58
|
await server.stop();
|
|
70
59
|
});
|
|
@@ -76,11 +65,8 @@ describe('Markdoc - render', () => {
|
|
|
76
65
|
await fixture.build();
|
|
77
66
|
|
|
78
67
|
const html = await fixture.readFile('/index.html');
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
expect(h2.textContent).to.equal('Simple post');
|
|
82
|
-
const p = document.querySelector('p');
|
|
83
|
-
expect(p.textContent).to.equal('This is a simple Markdoc post.');
|
|
68
|
+
|
|
69
|
+
renderSimpleChecks(html);
|
|
84
70
|
});
|
|
85
71
|
|
|
86
72
|
it('renders content - with config', async () => {
|
|
@@ -88,17 +74,8 @@ describe('Markdoc - render', () => {
|
|
|
88
74
|
await fixture.build();
|
|
89
75
|
|
|
90
76
|
const html = await fixture.readFile('/index.html');
|
|
91
|
-
const { document } = parseHTML(html);
|
|
92
|
-
const h2 = document.querySelector('h2');
|
|
93
|
-
expect(h2.textContent).to.equal('Post with config');
|
|
94
|
-
const textContent = html;
|
|
95
|
-
|
|
96
|
-
expect(textContent).to.not.include('Hello');
|
|
97
|
-
expect(textContent).to.include('Hola');
|
|
98
|
-
expect(textContent).to.include(`Konnichiwa`);
|
|
99
77
|
|
|
100
|
-
|
|
101
|
-
expect(runtimeVariable?.textContent?.trim()).to.equal('working!');
|
|
78
|
+
renderConfigChecks(html);
|
|
102
79
|
});
|
|
103
80
|
|
|
104
81
|
it('renders content - with components', async () => {
|
|
@@ -106,19 +83,68 @@ describe('Markdoc - render', () => {
|
|
|
106
83
|
await fixture.build();
|
|
107
84
|
|
|
108
85
|
const html = await fixture.readFile('/index.html');
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
expect(pre).to.not.be.null;
|
|
121
|
-
expect(pre.className).to.equal('astro-code');
|
|
86
|
+
|
|
87
|
+
renderComponentsChecks(html);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('renders content - with `render: null` in document', async () => {
|
|
91
|
+
const fixture = await getFixture('render-null');
|
|
92
|
+
await fixture.build();
|
|
93
|
+
|
|
94
|
+
const html = await fixture.readFile('/index.html');
|
|
95
|
+
|
|
96
|
+
renderNullChecks(html);
|
|
122
97
|
});
|
|
123
98
|
});
|
|
124
99
|
});
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @param {string} html
|
|
103
|
+
*/
|
|
104
|
+
function renderNullChecks(html) {
|
|
105
|
+
const { document } = parseHTML(html);
|
|
106
|
+
const h2 = document.querySelector('h2');
|
|
107
|
+
expect(h2.textContent).to.equal('Post with render null');
|
|
108
|
+
expect(h2.parentElement?.tagName).to.equal('BODY');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** @param {string} html */
|
|
112
|
+
function renderComponentsChecks(html) {
|
|
113
|
+
const { document } = parseHTML(html);
|
|
114
|
+
const h2 = document.querySelector('h2');
|
|
115
|
+
expect(h2.textContent).to.equal('Post with components');
|
|
116
|
+
|
|
117
|
+
// Renders custom shortcode component
|
|
118
|
+
const marquee = document.querySelector('marquee');
|
|
119
|
+
expect(marquee).to.not.be.null;
|
|
120
|
+
expect(marquee.hasAttribute('data-custom-marquee')).to.equal(true);
|
|
121
|
+
|
|
122
|
+
// Renders Astro Code component
|
|
123
|
+
const pre = document.querySelector('pre');
|
|
124
|
+
expect(pre).to.not.be.null;
|
|
125
|
+
expect(pre.className).to.equal('astro-code github-dark');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** @param {string} html */
|
|
129
|
+
function renderConfigChecks(html) {
|
|
130
|
+
const { document } = parseHTML(html);
|
|
131
|
+
const h2 = document.querySelector('h2');
|
|
132
|
+
expect(h2.textContent).to.equal('Post with config');
|
|
133
|
+
const textContent = html;
|
|
134
|
+
|
|
135
|
+
expect(textContent).to.not.include('Hello');
|
|
136
|
+
expect(textContent).to.include('Hola');
|
|
137
|
+
expect(textContent).to.include(`Konnichiwa`);
|
|
138
|
+
|
|
139
|
+
const runtimeVariable = document.querySelector('#runtime-variable');
|
|
140
|
+
expect(runtimeVariable?.textContent?.trim()).to.equal('working!');
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** @param {string} html */
|
|
144
|
+
function renderSimpleChecks(html) {
|
|
145
|
+
const { document } = parseHTML(html);
|
|
146
|
+
const h2 = document.querySelector('h2');
|
|
147
|
+
expect(h2.textContent).to.equal('Simple post');
|
|
148
|
+
const p = document.querySelector('p');
|
|
149
|
+
expect(p.textContent).to.equal('This is a simple Markdoc post.');
|
|
150
|
+
}
|