diff --git a/nuxt.config.js b/nuxt.config.js index 2703fc7923a4fba7566ed1f9cdce139fea518c94..94c3b7af99259988fbe9a6129ead9ddff72eef1e 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -206,9 +206,20 @@ export default { hooks: { // Netlifycms cannot create array in json file at root level and nuxt-content need an array. So, ressources.json is parsed to fetch 'ressources' key. 'content:file:beforeParse': (file) => { - if (file.extension !== '.json' || !/.*ressources.json$/.test(file.path)) - return - file.data = JSON.stringify(JSON.parse(file.data).ressources) + if (file.extension === '.json' && !/.*ressources.json$/.test(file.path)) { + file.data = JSON.stringify(JSON.parse(file.data).ressources) + } else if (file.extension === '.md') { + if (/^---.*layout:.*---/s.test(file.data)) { + let t = 0 + const data = file.data.replace(/---/g, (match) => { + ++t + if (t === 2) return '---\n<section>' + if (t > 2) return '</section>\n<section>' + return match + }) + file.data = data + '\n</section>' + } + } }, async 'content:file:beforeInsert'(document) { if (document.extension === '.md') {