Add modal to tag count with direct links to other examples

This commit is contained in:
Maximilian Krög
2020-07-25 10:20:03 +02:00
parent 50404ca409
commit 9093478016
3 changed files with 83 additions and 2 deletions

View File

@@ -18,6 +18,13 @@ handlebars.registerHelper(
(str) => new handlebars.SafeString(marked(str))
);
/**
* Used to doube-escape the title when stored as data-* attribute.
*/
handlebars.registerHelper('escape', (text) => {
return handlebars.Utils.escapeExpression(text);
});
handlebars.registerHelper('indent', (text, options) => {
if (!text) {
return text;
@@ -205,9 +212,17 @@ class ExampleBuilder {
};
exampleData.forEach((data) => {
data.tags = data.tags.map((tag) => {
const tagExamples = tagIndex[tag.toLowerCase()];
return {
tag: tag,
amount: tagIndex[tag.toLowerCase()].length,
examples: tagExamples.map((exampleIdx) => {
const example = examples[exampleIdx];
return {
link: example.link,
title: example.title,
isCurrent: data.filename === example.link,
};
}),
};
});
});