|
|
@ -3,9 +3,8 @@ import path from 'path';
|
|
|
|
import process_markdown from '../../../utils/_process_markdown.js';
|
|
|
|
import process_markdown from '../../../utils/_process_markdown.js';
|
|
|
|
import marked from 'marked';
|
|
|
|
import marked from 'marked';
|
|
|
|
|
|
|
|
|
|
|
|
// import hljs from 'highlight.js';
|
|
|
|
import PrismJS from 'prismjs';
|
|
|
|
import prismjs from 'prismjs'; // prism-highlighter – smaller footprint [hljs: 192.5k]
|
|
|
|
import 'prismjs/components/prism-bash';
|
|
|
|
require('prismjs/components/prism-bash');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// map lang to prism-language-attr
|
|
|
|
// map lang to prism-language-attr
|
|
|
|
const prismLang = {
|
|
|
|
const prismLang = {
|
|
|
@ -31,10 +30,10 @@ export default function() {
|
|
|
|
const renderer = new marked.Renderer();
|
|
|
|
const renderer = new marked.Renderer();
|
|
|
|
|
|
|
|
|
|
|
|
renderer.code = (source, lang) => {
|
|
|
|
renderer.code = (source, lang) => {
|
|
|
|
let plang = prismLang[lang];
|
|
|
|
const plang = prismLang[lang];
|
|
|
|
const highlighted = Prism.highlight(
|
|
|
|
const highlighted = PrismJS.highlight(
|
|
|
|
source,
|
|
|
|
source,
|
|
|
|
Prism.languages[plang],
|
|
|
|
PrismJS.languages[plang],
|
|
|
|
lang,
|
|
|
|
lang,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
@ -43,9 +42,7 @@ export default function() {
|
|
|
|
|
|
|
|
|
|
|
|
const html = marked(
|
|
|
|
const html = marked(
|
|
|
|
content.replace(/^\t+/gm, match => match.split('\t').join(' ')),
|
|
|
|
content.replace(/^\t+/gm, match => match.split('\t').join(' ')),
|
|
|
|
{
|
|
|
|
{ renderer }
|
|
|
|
renderer,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
@ -54,7 +51,5 @@ export default function() {
|
|
|
|
slug: file.replace(/^[\d-]+/, '').replace(/\.md$/, ''),
|
|
|
|
slug: file.replace(/^[\d-]+/, '').replace(/\.md$/, ''),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.sort((a, b) => {
|
|
|
|
.sort((a, b) => a.metadata.pubdate < b.metadata.pubdate ? 1 : -1);
|
|
|
|
return a.metadata.pubdate < b.metadata.pubdate ? 1 : -1;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|