debuglog: debuglog('blog'),
buildUrl(id, slug) {
+
return `./${id}/${slug}`;
},
- buildTitle (id, slug) {
+ buildTitle(id, slug) {
+
const date = new Date(Number(id));
- const shortDate = date.toISOString().split('T')[0]
+ const shortDate = date.toISOString().split('T')[0];
const title = slug.split('-').join(' ');
- return `${shortDate} ${title}`
+ return `${shortDate} ${title}`;
},
buildLink(id, slug) {
+
return `=> ${internals.buildUrl(id,slug)} ${internals.buildTitle(id,slug)}`;
}
};
-export default async function(templateDirectory, source, target) {
+export default async function (templateDirectory, source, target) {
+
internals.debuglog(`Reading archive ${source}`);
const postIds = (await readdir(source))
.sort((a, b) => Number(b) - Number(a));
for (const id of postIds) {
const postDirectory = join(source, id);
const slug = (await readdir(postDirectory))
- .filter((entry) => internals.kGeminiRe.test(entry))[0];
+ .filter((entry) => internals.kGeminiRe.test(entry))[0];
- posts.push({ id, slug })
- };
+ posts.push({ id, slug });
+ }
internals.debuglog(`Read ${posts.length} posts`);
...Dot.templateSettings,
strip: false
})({
- posts: posts.map((post) => internals.buildLink(post.id, post.slug)).join('\n'),
+ posts: posts.map((post) => internals.buildLink(post.id, post.slug)).join('\n')
});
try {
internals.debuglog('Copying posts to archive');
await cp(source, target, { recursive: true });
}
-};
+}