site: API docs, transform section titles with the same processor used for content headers

pull/2498/head
Luca Bonavita 6 years ago committed by Conduitry
parent d85de6791e
commit 2a76b8d383

@ -48,6 +48,8 @@ export default function() {
const { content, metadata } = extract_frontmatter(markdown);
const sectionSlug = makeSlug(metadata.title);
const subsections = [];
const renderer = new marked.Renderer();
@ -142,7 +144,7 @@ export default function() {
html: html.replace(/@@(\d+)/g, (m, id) => hashes[id] || m),
metadata,
subsections,
slug: file.replace(/^\d+-/, '').replace(/\.md$/, ''),
slug: sectionSlug,
file,
};
});

@ -45,10 +45,10 @@ export const langs = {
// links renderer
export function link_renderer(href,title,text) {
export function link_renderer (href, title, text) {
let target_attr = '';
let title_attr = '';
if(href.startsWith("http")) {
target_attr = ' target="_blank"';
}
@ -56,6 +56,6 @@ export function link_renderer(href,title,text) {
if(title !== null) {
title_attr = ` title="${title}"`;
}
return `<a href="${href}"${target_attr}${title_attr}>${text}</a>`;
};
};

@ -17,13 +17,6 @@ const unicodeRegex = /\p{Letter}/u;
const isNonAlphaNumUnicode =
string => !alphaNumRegex.test(string) && unicodeRegex.test(string);
const nonUnicodeSanitizer = string =>
string
.toLowerCase()
.replace(/[^a-zA-Z0-9]+/g, '-')
.replace(/^-/, '')
.replace(/-$/, '');
export const unicodeSafeProcessor = string =>
string.split('')
.reduce((accum, char, index, array) => {
@ -48,7 +41,6 @@ export const unicodeSafeProcessor = string =>
.reduce((accum, chunk) => {
const processed = chunk.type === 'process'
? limaxProcessor(chunk.string)
// ? nonUnicodeSanitizer(chunk.string)
: chunk.string;
processed.length > 0 && accum.push(processed);

Loading…
Cancel
Save