Commit 00f61240 authored by  JosephK's avatar JosephK
Browse files

Merge branch 'master' into 'master'

[wiki] fix frontmatter parsing

See merge request !232
parents 09b0788c 9cdeaf45
Pipeline #443203 passed with stages
in 2 minutes and 36 seconds
......@@ -8,7 +8,7 @@ function formatWiki(env, data) {
for (let i = 0; i < json.length; i += 1) {
const front = json[i].content.match(/^---([\s\S]*)---/m)
? json[i].content.match(/^---([\s\S]*)---/m)[0]
? json[i].content.split('---')[1]
: '';
const lg = front.match(/lang: ([a-zA-Z_]+)/)
......@@ -23,6 +23,10 @@ function formatWiki(env, data) {
? front.match(/title: (.+)/)[1] /* alternative title */
: json[i].title; /* tile from .md filename (- and / are not allowed) */
let img = front.match(/img: (.+)/)
? front.match(/img: (.+)/)[1]
: '';
/* settings for news */
const date = front.match(/date: ([0-9]{2}-[0-9]{2}-[0-9]{2})/)
? front.match(/date: ([0-9]{2}-[0-9]{2}-[0-9]{2})/)[1]
......@@ -53,10 +57,10 @@ function formatWiki(env, data) {
// Replace wiki relative links by local links
.replace(/\]\(uploads\//gm, `](${env.url}wiki/`)
// Remove front matter
.replace(front, '');
.replace(`---${front}---`, '');
/* Extract data */
const img = content.match(/^!\[.*\]\((.*?)\)/m)
img = content.match(/^!\[.*\]\((.*?)\)/m)
? content.match(/^!\[.*\]\((.*?)\)/m)[1]
: '';
const text = content
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment