Skip to content

Commit 5fb9924

Browse files
committed
feat: Support graymatter headers to asciidoc files when enabled
1 parent c2d42ec commit 5fb9924

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

packages/gatsby-transformer-asciidoc/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ In the asciidoc file you can insert your image just by using:
8585
- In case a `pathPrefix` is set it will altered the images location.
8686
- In case you want to be able to override the defined imagesdir inside of your asciidoc file you have to end the path with a `@` (e.g. `/images@`).
8787

88+
## Support front/graymatter
89+
90+
```javascript
91+
// In your gatsby-config.js
92+
plugins: [
93+
{
94+
resolve: `gatsby-transformer-asciidoc`,
95+
options: {
96+
attributes: {
97+
"skip-front-matter": true,
98+
},
99+
},
100+
},
101+
]
102+
```
103+
88104
## How to query
89105

90106
A sample GraphQL query to get AsciiDoc nodes:

packages/gatsby-transformer-asciidoc/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
},
99
"dependencies": {
1010
"@babel/runtime": "^7.15.4",
11-
"asciidoctor": "^2.2.5"
11+
"asciidoctor": "^2.2.5",
12+
"gray-matter": "^4.0.2"
1213
},
1314
"devDependencies": {
1415
"@babel/cli": "^7.15.4",

packages/gatsby-transformer-asciidoc/src/gatsby-node.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const asciidoc = require(`asciidoctor`)()
2+
const grayMatter = require(`gray-matter`)
23
const _ = require(`lodash`)
34

45
function unstable_shouldOnCreateNode({ node }, pluginOptions = {}) {
@@ -97,6 +98,10 @@ async function onCreateNode(
9798
pageAttributes,
9899
}
99100

101+
if (doc.getAttribute(`front-matter`)) {
102+
asciiNode.frontmatter = grayMatter(doc.getAttribute(`front-matter`))
103+
}
104+
100105
asciiNode.internal.contentDigest = createContentDigest(asciiNode)
101106

102107
createNode(asciiNode)

0 commit comments

Comments
 (0)