diff options
| author | Ruben Beltran del Rio <git@r.bdr.sh> | 2024-02-14 17:15:11 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <git@r.bdr.sh> | 2024-02-14 17:15:11 +0100 |
| commit | 10a76a5bf0a9d051aa9432566088034c5ced714b (patch) | |
| tree | fe2999541841f7f9c74839bb2835d4a050696890 /lib/archivers | |
| parent | 6cd62e795e3716aa0cbd2d1ff8c1b3a345803563 (diff) | |
Lint
Diffstat (limited to 'lib/archivers')
| -rw-r--r-- | lib/archivers/gemlog.js | 22 |
1 files changed, 13 insertions, 9 deletions
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 }); } -}; +} |