Move Uncategorized to the end
This commit is contained in:
@ -69,21 +69,38 @@ catch (err){ // Handle errors (hopefully not!)
|
|||||||
try {
|
try {
|
||||||
// Add the start static part
|
// Add the start static part
|
||||||
output += `${startPart+'\n'}`;
|
output += `${startPart+'\n'}`;
|
||||||
|
let uncategorizedOutput = '';
|
||||||
// Loop over tags and snippets to create the table of contents
|
// Loop over tags and snippets to create the table of contents
|
||||||
for(let tag of [...new Set(Object.entries(tagDbData).map(t => t[1]))].filter(v => v).sort((a,b) => a.localeCompare(b))){
|
for(let tag of [...new Set(Object.entries(tagDbData).map(t => t[1]))].filter(v => v).sort((a,b) => a.localeCompare(b))){
|
||||||
output +=`<h3>`+md.render(`${capitalize(tag, true)}\n`).replace(/<p>/g,'').replace(/<\/p>/g,'')+`</h3>`;
|
if(capitalize(tag, true)=='Uncategorized') {
|
||||||
for(let taggedSnippet of Object.entries(tagDbData).filter(v => v[1] === tag))
|
uncategorizedOutput +=`<h3>`+md.render(`${capitalize(tag, true)}\n`).replace(/<p>/g,'').replace(/<\/p>/g,'')+`</h3>`;
|
||||||
output += md.render(`[${taggedSnippet[0]}](#${taggedSnippet[0].toLowerCase()})\n`).replace(/<p>/g,'').replace(/<\/p>/g,'').replace(/<a/g,'<a class="sublink-1"');
|
for(let taggedSnippet of Object.entries(tagDbData).filter(v => v[1] === tag))
|
||||||
output += '\n';
|
uncategorizedOutput += md.render(`[${taggedSnippet[0]}](#${taggedSnippet[0].toLowerCase()})\n`).replace(/<p>/g,'').replace(/<\/p>/g,'').replace(/<a/g,'<a class="sublink-1"');
|
||||||
|
uncategorizedOutput += '\n';
|
||||||
|
} else {
|
||||||
|
output +=`<h3>`+md.render(`${capitalize(tag, true)}\n`).replace(/<p>/g,'').replace(/<\/p>/g,'')+`</h3>`;
|
||||||
|
for(let taggedSnippet of Object.entries(tagDbData).filter(v => v[1] === tag))
|
||||||
|
output += md.render(`[${taggedSnippet[0]}](#${taggedSnippet[0].toLowerCase()})\n`).replace(/<p>/g,'').replace(/<\/p>/g,'').replace(/<a/g,'<a class="sublink-1"');
|
||||||
|
output += '\n';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
output += uncategorizedOutput;
|
||||||
output += `</nav><main class="col-sm-12 col-md-8 col-lg-9" style="height: 100%;overflow-y: auto; background: #eceef2; padding: 0;">`;
|
output += `</nav><main class="col-sm-12 col-md-8 col-lg-9" style="height: 100%;overflow-y: auto; background: #eceef2; padding: 0;">`;
|
||||||
output += `<a id="top"> </a>`;
|
output += `<a id="top"> </a>`;
|
||||||
|
uncategorizedOutput = '';
|
||||||
// Loop over tags and snippets to create the list of snippets
|
// Loop over tags and snippets to create the list of snippets
|
||||||
for(let tag of [...new Set(Object.entries(tagDbData).map(t => t[1]))].filter(v => v).sort((a,b) => a.localeCompare(b))){
|
for(let tag of [...new Set(Object.entries(tagDbData).map(t => t[1]))].filter(v => v).sort((a,b) => a.localeCompare(b))){
|
||||||
output +=md.render(`## ${capitalize(tag, true)}\n`).replace(/<h2>/g,'<h2 style="text-align:center;">');
|
if(capitalize(tag, true)=='Uncategorized') {
|
||||||
for(let taggedSnippet of Object.entries(tagDbData).filter(v => v[1] === tag))
|
uncategorizedOutput +=md.render(`## ${capitalize(tag, true)}\n`).replace(/<h2>/g,'<h2 style="text-align:center;">');
|
||||||
output += '<div class="card fluid"><div class="section double-padded">' + md.render(`\n${snippets[taggedSnippet[0]+'.md']}`).replace(/<h3/g,`<h3 id="${taggedSnippet[0].toLowerCase()}"`).replace(/<\/h3>/g,'</h3></div><div class="section double-padded">') + '</div></div><br/>';
|
for(let taggedSnippet of Object.entries(tagDbData).filter(v => v[1] === tag))
|
||||||
|
uncategorizedOutput += '<div class="card fluid"><div class="section double-padded">' + md.render(`\n${snippets[taggedSnippet[0]+'.md']}`).replace(/<h3/g,`<h3 id="${taggedSnippet[0].toLowerCase()}"`).replace(/<\/h3>/g,'</h3></div><div class="section double-padded">') + '</div></div><br/>';
|
||||||
|
} else {
|
||||||
|
output +=md.render(`## ${capitalize(tag, true)}\n`).replace(/<h2>/g,'<h2 style="text-align:center;">');
|
||||||
|
for(let taggedSnippet of Object.entries(tagDbData).filter(v => v[1] === tag))
|
||||||
|
output += '<div class="card fluid"><div class="section double-padded">' + md.render(`\n${snippets[taggedSnippet[0]+'.md']}`).replace(/<h3/g,`<h3 id="${taggedSnippet[0].toLowerCase()}"`).replace(/<\/h3>/g,'</h3></div><div class="section double-padded">') + '</div></div><br/>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
output += uncategorizedOutput;
|
||||||
// Add the ending static part
|
// Add the ending static part
|
||||||
output += `\n${endPart+'\n'}`;
|
output += `\n${endPart+'\n'}`;
|
||||||
// Minify output
|
// Minify output
|
||||||
|
|||||||
Reference in New Issue
Block a user