Bauke/tildes-issue-log
Bauke
/
tildes-issue-log
Archived
1
Fork 0
This repository has been archived on 2022-10-04. You can view files and clone it, but cannot push or open issues or pull requests.
tildes-issue-log/source/scripts/redirects.ts

38 lines
953 B
TypeScript

import {promises as fsp} from 'fs';
import {join} from 'path';
import nunjucks from 'nunjucks';
import {renderTemplate, months} from './html';
async function entry(): Promise<void> {
const redirectDirectory: string = join(__dirname, '../../public/posts/');
await fsp.mkdir(redirectDirectory, {recursive: true});
nunjucks.configure(join(__dirname, '../pages/templates/'), {
lstripBlocks: true,
throwOnUndefined: true,
trimBlocks: true
});
for (let year = 2018; year < new Date().getFullYear() + 1; year++) {
for (let monthNumber = 1; monthNumber < 13; monthNumber++) {
if (year === 2018 && monthNumber < 5) {
continue;
}
const month: string = months[monthNumber];
await renderTemplate(
'redirect.html',
join(redirectDirectory, `${month}-${year}.html`),
{
month,
year
}
);
}
}
}
if (require.main === module) {
void entry();
}