redzuurdesem/jamstack-init.js

45 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-03-05 14:18:21 +01:00
2021-06-15 20:52:35 +02:00
const { mastodon, goodreads, lunr, webmention, youtube } = require('jam-my-stack');
2021-03-05 14:18:21 +01:00
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
};
2021-03-05 14:18:21 +01:00
(async function() {
// 1. build Lunr index
console.log("1. Building lunr search index...")
const index = await lunr.buildIndex([
`${__dirname}/content/post`,
`${__dirname}/content/kort`,
2021-03-05 14:18:21 +01:00
`${__dirname}/content/leren`])
await fsp.writeFile(`${__dirname}/static/js/redzuurdesem-post.json`, JSON.stringify(index), 'utf-8')
2021-06-15 20:52:35 +02:00
// 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(`${__dirname}/data/webmentions.json`, json, 'utf-8')
2021-06-15 20:52:35 +02:00
// 3. send webmentions
console.log("3. Sending webmentions...")
const since = await webmention.send("redzuurdesem.be", wmconfig)
console.log(` -- done`)
2021-06-15 20:52:35 +02:00
// 4. build youtube thumbnails
console.log("4. building youtube thumbnails...")
await youtube.thumbify({
postDir: `${__dirname}/content`,
downloadDir: `${__dirname}/static/images/yt`,
overlayImg: `${__dirname}/play.png`
})
2021-03-05 14:18:21 +01:00
console.log("-- all done!")
})()