X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/6cd62e795e3716aa0cbd2d1ff8c1b3a345803563..refs/heads/rust:/lib/archivers/gemlog.js?ds=sidebyside diff --git a/lib/archivers/gemlog.js b/lib/archivers/gemlog.js index d56a1f6..1bb0c10 100644 --- a/lib/archivers/gemlog.js +++ b/lib/archivers/gemlog.js @@ -11,22 +11,26 @@ const internals = { 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)); @@ -34,10 +38,10 @@ export default async function(templateDirectory, source, target) { 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`); @@ -52,7 +56,7 @@ export default async function(templateDirectory, source, target) { ...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 { @@ -68,4 +72,4 @@ export default async function(templateDirectory, source, target) { internals.debuglog('Copying posts to archive'); await cp(source, target, { recursive: true }); } -}; +}