Script cleanup
This commit is contained in:
@ -121,21 +121,7 @@ console.log(tagDbData);
|
|||||||
|
|
||||||
// Create the output for the README file
|
// Create the output for the README file
|
||||||
try {
|
try {
|
||||||
const tags = [
|
const tags = util.prepTaggedData(tagDbData);
|
||||||
...new Set(
|
|
||||||
Object.entries(tagDbData)
|
|
||||||
.map(t => t[1][0])
|
|
||||||
.filter(v => v)
|
|
||||||
.sort(
|
|
||||||
(a, b) =>
|
|
||||||
util.capitalize(a, true) === 'Uncategorized'
|
|
||||||
? 1
|
|
||||||
: util.capitalize(b, true) === 'Uncategorized'
|
|
||||||
? -1
|
|
||||||
: a.localeCompare(b)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
];
|
|
||||||
|
|
||||||
// Add the start static part
|
// Add the start static part
|
||||||
output += `${startPart}\n`;
|
output += `${startPart}\n`;
|
||||||
|
|||||||
@ -140,6 +140,16 @@ const getTextualContent = str => {
|
|||||||
}
|
}
|
||||||
return results[1];
|
return results[1];
|
||||||
};
|
};
|
||||||
|
const prepTaggedData = tagDbData => [...new Set(Object.entries(tagDbData).map(t => t[1][0]))]
|
||||||
|
.filter(v => v)
|
||||||
|
.sort(
|
||||||
|
(a, b) =>
|
||||||
|
capitalize(a, true) === 'Uncategorized'
|
||||||
|
? 1
|
||||||
|
: capitalize(b, true) === 'Uncategorized'
|
||||||
|
? -1
|
||||||
|
: a.localeCompare(b)
|
||||||
|
);
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getMarkDownAnchor,
|
getMarkDownAnchor,
|
||||||
getFilesInDir,
|
getFilesInDir,
|
||||||
@ -153,5 +163,6 @@ module.exports = {
|
|||||||
shuffle,
|
shuffle,
|
||||||
getCodeBlocks,
|
getCodeBlocks,
|
||||||
getTextualContent,
|
getTextualContent,
|
||||||
isNotTravisCronOrAPI
|
isNotTravisCronOrAPI,
|
||||||
|
prepTaggedData
|
||||||
};
|
};
|
||||||
|
|||||||
@ -158,16 +158,7 @@ tagDbData = util.readTags();
|
|||||||
|
|
||||||
// Create the output for individual category pages
|
// Create the output for individual category pages
|
||||||
try {
|
try {
|
||||||
let taggedData = [...new Set(Object.entries(tagDbData).map(t => t[1][0]))]
|
let taggedData = util.prepTaggedData(tagDbData);
|
||||||
.filter(v => v)
|
|
||||||
.sort(
|
|
||||||
(a, b) =>
|
|
||||||
util.capitalize(a, true) === 'Uncategorized'
|
|
||||||
? 1
|
|
||||||
: util.capitalize(b, true) === 'Uncategorized'
|
|
||||||
? -1
|
|
||||||
: a.localeCompare(b)
|
|
||||||
);
|
|
||||||
// Add the start static part
|
// Add the start static part
|
||||||
output += `${startPart}${'\n'}`;
|
output += `${startPart}${'\n'}`;
|
||||||
// Loop over tags and snippets to create the table of contents
|
// Loop over tags and snippets to create the table of contents
|
||||||
|
|||||||
Reference in New Issue
Block a user