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

pull/2498/head
Luca Bonavita 5 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,
};
});

@ -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