Skip to content

Commit 6b57ee5

Browse files
committed
Switch to js-yaml for easy flow formatting
attributes: foo: bar articles: [+Article:author] is much better than: attributes: foo: bar articles: - +Article:author Fix was thanks to the flowLevel option in js-yaml
1 parent e95bae5 commit 6b57ee5

File tree

3 files changed

+90
-33
lines changed

3 files changed

+90
-33
lines changed

package-lock.json

Lines changed: 84 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737
"express": "^4.18.2",
3838
"front-matter": "^4.0.2",
3939
"handlebars": "^4.7.7",
40+
"js-yaml": "^4.1.1",
4041
"lodash": "^4.17.21",
4142
"marked": "^4.2.5",
4243
"posthtml": "^0.16.6",
4344
"posthtml-urls": "^1.0.0",
4445
"slug": "^8.2.3",
45-
"turndown": "^7.1.1",
46-
"yaml": "^2.8.2"
46+
"turndown": "^7.1.1"
4747
},
4848
"devDependencies": {
4949
"cheerio": "^1.1.2",

src/cms/api/models/contentTypes.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
const { join } = require('path')
22
const { mkdir, writeFile } = require('fs/promises')
3-
const { stringify } = require('yaml')
3+
const { dump } = require('js-yaml')
44

55
const createContentTypesModel = ({ getSettings, getContentTypes }) => {
66
const createContentType = async ({ name, description = '', attributes, ...config }) => {
77
const { rootDirectory } = getSettings()
88
const schemaDirectory = join(rootDirectory, 'schema')
99
const filePath = join(schemaDirectory, `${name}.md`)
10-
const frontMatter = stringify({
10+
const frontMatter = dump({
1111
name,
1212
attributes,
1313
...config
14+
}, {
15+
flowLevel: 2
1416
})
1517
const fileContent = ['---', frontMatter.replace(/\s+$/, ''), '---', description].join('\n')
1618
await mkdir(schemaDirectory, { recursive: true })

0 commit comments

Comments
 (0)