42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
|
|
const { mastodon, goodreads, lunr, webmention, youtube } = require('jam-my-stack');
|
|
const fsp = require('fs').promises;
|
|
|
|
if(!process.env.WEBMENTION_TOKEN) {
|
|
throw "No webmention token set!"
|
|
}
|
|
|
|
const wmconfig = {
|
|
endpoint: 'https://jam.brainbaking.com',
|
|
token: process.env.WEBMENTION_TOKEN
|
|
};
|
|
|
|
const rootdir = `${__dirname}/../`;
|
|
|
|
(async function() {
|
|
// 1. build Lunr index
|
|
console.log("1. Building lunr search index...")
|
|
const index = await lunr.buildIndex([
|
|
`${rootdir}/content/post`,
|
|
`${rootdir}/content/kort`,
|
|
`${rootdir}/content/leren`])
|
|
await fsp.writeFile(`${rootdir}/static/js/redzuurdesem-post.json`, JSON.stringify(index), 'utf-8')
|
|
|
|
// 2. get webmentions
|
|
console.log("2. Fetching webmentions...")
|
|
const mentions = await webmention.getWebmentions("redzuurdesem.be", wmconfig)
|
|
const json = JSON.stringify(mentions, null, 4)
|
|
await fsp.writeFile(`${rootdir}/data/webmentions.json`, json, 'utf-8')
|
|
|
|
// 3. build youtube thumbnails
|
|
console.log("4. building youtube thumbnails...")
|
|
await youtube.thumbify({
|
|
postDir: `${rootdir}/content`,
|
|
downloadDir: `${rootdir}/static/images/yt`,
|
|
overlayImg: `${rootdir}/play.png`
|
|
})
|
|
|
|
|
|
console.log("-- all done!")
|
|
})()
|