Skip to content

Commit

Permalink
chore: Add whats new id deletion logic
Browse files Browse the repository at this point in the history
  • Loading branch information
LizBaker committed Oct 19, 2021
1 parent c5e8aa2 commit 79a7b3f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scripts/actions/generate-whats-new-ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,23 @@ const generateWhatsNewIds = async () => {
);

return new Promise((resolve) => {
const currentWhatsNewPaths = [];
vfileGlob('./src/content/whats-new/**/*.md').subscribe({
next: (file) => {
const slug = file.path
.replace(/.*?src\/content/, '')
.replace('.md', '');

currentWhatsNewPaths.push(slug);
if (!data[slug]) {
data[slug] = String(++largestID);
}
},
complete: async () => {
Object.entries(data).forEach(([path]) => {
if (!currentWhatsNewPaths.includes(path)) {
delete data[path];
}
});
file.contents = JSON.stringify(data, null, 2);

await write(file, 'utf-8');
Expand Down

0 comments on commit 79a7b3f

Please sign in to comment.