-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(markdoc): allowIndentation integration option (#8802)
- Loading branch information
1 parent
341ef65
commit 73b8d60
Showing
13 changed files
with
194 additions
and
1 deletion.
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': minor | ||
--- | ||
|
||
Added ignoreIndentation as a markdoc integration option to enable better readability of source code. |
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export interface MarkdocIntegrationOptions { | ||
allowHTML?: boolean; | ||
ignoreIndentation?: boolean; | ||
} |
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-with-indented-components/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({ ignoreIndentation: true })], | ||
}); |
26 changes: 26 additions & 0 deletions
26
...ages/integrations/markdoc/test/fixtures/render-with-indented-components/markdoc.config.ts
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, component } 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', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) |
9 changes: 9 additions & 0 deletions
9
packages/integrations/markdoc/test/fixtures/render-with-indented-components/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-with-indented-components", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/markdoc": "workspace:*", | ||
"astro": "workspace:*" | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...egrations/markdoc/test/fixtures/render-with-indented-components/src/components/Code.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,12 @@ | ||
--- | ||
import { Code } from 'astro/components'; | ||
type Props = { | ||
content: string; | ||
language: string; | ||
} | ||
const { content, language } = Astro.props as Props; | ||
--- | ||
|
||
<Code lang={language} code={content} /> |
1 change: 1 addition & 0 deletions
1
.../markdoc/test/fixtures/render-with-indented-components/src/components/CustomMarquee.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 @@ | ||
<marquee data-custom-marquee {...Astro.props}><slot /></marquee> |
24 changes: 24 additions & 0 deletions
24
...t/fixtures/render-with-indented-components/src/content/blog/with-indented-components.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,24 @@ | ||
--- | ||
title: Post with indented components | ||
--- | ||
|
||
## Post with indented components | ||
|
||
This uses a custom marquee component with a shortcode: | ||
|
||
{% marquee-element direction="right" %} | ||
I'm a marquee too! | ||
|
||
{% marquee-element direction="right" %} | ||
I'm an indented marquee! | ||
|
||
### I am an h3! | ||
{% /marquee-element %} | ||
|
||
And a nested code block: | ||
|
||
```js | ||
const isRenderedWithShiki = true; | ||
``` | ||
{% /marquee-element %} | ||
|
19 changes: 19 additions & 0 deletions
19
.../integrations/markdoc/test/fixtures/render-with-indented-components/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', 'with-indented-components'); | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.