refactor: now using marked for changelog

Signed-off-by: Corentin Thomasset <corentin.thomasset74@gmail.com>
This commit is contained in:
Corentin Thomasset 2020-06-14 20:52:43 +02:00 committed by Corentin THOMASSET
parent 507d961cd8
commit 9fc566e55a

View file

@ -11,7 +11,7 @@
</v-col> </v-col>
</v-row> </v-row>
<v-row justify="center" > <v-row justify="center">
<v-col cols="12" md="5" sm="12"> <v-col cols="12" md="5" sm="12">
<v-card> <v-card>
<v-card-title>Contributors</v-card-title> <v-card-title>Contributors</v-card-title>
@ -22,12 +22,7 @@
<v-card> <v-card>
<v-card-title>Changelog</v-card-title> <v-card-title>Changelog</v-card-title>
<v-card-text> <v-card-text>
<div v-for="(section, i) in changelog" :key="i"> <div v-html="changelog" class="changelog">
<h2>{{section.title}}</h2>
<ul>
<li v-for="(log, i) in section.logs" :key="i"> {{log}}</li>
</ul>
<br>
</div> </div>
</v-card-text> </v-card-text>
</v-card> </v-card>
@ -39,6 +34,8 @@
import Abstract from "../components/Abstract"; import Abstract from "../components/Abstract";
import GithubContributors from "../components/GithubContributors"; import GithubContributors from "../components/GithubContributors";
import changelog from "../../CHANGELOG.md" import changelog from "../../CHANGELOG.md"
import marked from 'marked'
import DOMPurify from 'dompurify';
export default { export default {
name: "About", name: "About",
@ -46,24 +43,7 @@
changelog: [] changelog: []
}), }),
mounted() { mounted() {
this.changelog = DOMPurify.sanitize(marked('##' + changelog.replace(/^(.*?)##/s, '')));
this.changelog = ('##' + changelog.replace(/^(.*?)##/s, ''))
.split('\n')
.filter(v => v !== '')
.reduce((sections, v) => {
v = v.trim();
if(v.startsWith('##')){
sections.push({
title: v.replace(/^##/, '').trim(),
logs: []
})
}else {
sections.slice(-1)[0].logs.push(v.replace(/^-/, '').trim())
}
return sections
}, []);
console.log(this.changelog);
}, },
components: { components: {
Abstract, Abstract,
@ -71,3 +51,13 @@
}, },
} }
</script> </script>
<style scoped lang="less">
::v-deep {
.changelog {
h2 {
margin-top: 10px;
}
}
}
</style>