-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Markdoc] Fix: Support
render: null
(#6723)
* fix: handle array of tree nodes * test: render null in document node * chore: lock * refactor: consolidate render test logic * chore: changeset
- Loading branch information
1 parent
ad80d83
commit 73fcc76
Showing
9 changed files
with
309 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/markdoc': patch | ||
--- | ||
|
||
Fix: when using `render: null` in your config, content is now rendered without a wrapper element. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/integrations/markdoc/test/fixtures/render-null/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import markdoc from '@astrojs/markdoc'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
integrations: [markdoc()], | ||
}); |
26 changes: 26 additions & 0 deletions
26
packages/integrations/markdoc/test/fixtures/render-null/markdoc.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { defineMarkdocConfig } from '@astrojs/markdoc/config'; | ||
|
||
export default defineMarkdocConfig({ | ||
nodes: { | ||
document: { | ||
render: null, | ||
|
||
// Defaults from `Markdoc.nodes.document` | ||
children: [ | ||
'heading', | ||
'paragraph', | ||
'image', | ||
'table', | ||
'tag', | ||
'fence', | ||
'blockquote', | ||
'comment', | ||
'list', | ||
'hr', | ||
], | ||
attributes: { | ||
frontmatter: { render: false }, | ||
}, | ||
} | ||
} | ||
}) |
9 changes: 9 additions & 0 deletions
9
packages/integrations/markdoc/test/fixtures/render-null/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@test/markdoc-render-null", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/markdoc": "workspace:*", | ||
"astro": "workspace:*" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/integrations/markdoc/test/fixtures/render-null/src/content/blog/render-null.mdoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: Post with render null | ||
--- | ||
|
||
## Post with render null | ||
|
||
This should render the contents inside a fragment! |
19 changes: 19 additions & 0 deletions
19
packages/integrations/markdoc/test/fixtures/render-null/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
import { getEntryBySlug } from "astro:content"; | ||
const post = await getEntryBySlug('blog', 'render-null'); | ||
const { Content } = await post.render(); | ||
--- | ||
|
||
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.