generate-examples-index-webpack-plugin
Version:
Generate an examples index page from your examples folder
30 lines (25 loc) • 707 B
JavaScript
/**
* Generate the index list HTML from the examples info
*
* @param info Object from getExamplesInfo
* @return HTML code
*/
function getIndexListHtml(info) {
const res = [];
info.examples.forEach((example, i) => {
const listHtmls = example.cases.map((entry) => `
<a class="list-group-item" href="${entry.route}">
<b>${entry.name}:</b>
<em>${entry.title}</em>
</a>
`);
res.push(`
<div class="list-group shadow my-4">
<h5 class="list-group-item list-group-item-primary">${example.folderName}/</h5>
${listHtmls.join('\n')}
</div>`
);
});
return `<div id="examples">${res.join('\n')}</div>`;
}
module.exports = getIndexListHtml;