split jamstack-init into precommit and postdeploy to send webmentions AFTER deploying
This commit is contained in:
parent
031d72a523
commit
4ad750a8d1
|
@ -1,4 +1,18 @@
|
||||||
[
|
[
|
||||||
|
{
|
||||||
|
"author": {
|
||||||
|
"name": "Wouter Groeneveld",
|
||||||
|
"picture": "/pictures/brainbaking.com"
|
||||||
|
},
|
||||||
|
"name": "",
|
||||||
|
"content": "Hi Ana hope you’re doing well! The Webmention Guestbook idea is awesome! Looking forward to your future blog posts.",
|
||||||
|
"published": "2022-04-26T12:06:00+00:00",
|
||||||
|
"url": "https://brainbaking.com/notes/2022/04/26h12m06s10/",
|
||||||
|
"type": "mention",
|
||||||
|
"source": "https://brainbaking.com/notes/2022/04/26h12m06s10/",
|
||||||
|
"target": "https://brainbaking.com/",
|
||||||
|
"relativeTarget": "/"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Chris Burnell",
|
"name": "Chris Burnell",
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
const { webmention } = require('jam-my-stack');
|
||||||
|
|
||||||
|
if(!process.env.WEBMENTION_TOKEN) {
|
||||||
|
throw "No webmention token set!"
|
||||||
|
}
|
||||||
|
|
||||||
|
const wmconfig = {
|
||||||
|
endpoint: 'https://jam.brainbaking.com',
|
||||||
|
token: process.env.WEBMENTION_TOKEN
|
||||||
|
};
|
||||||
|
|
||||||
|
(async function() {
|
||||||
|
// 1. send webmentions
|
||||||
|
console.log("1. Sending webmentions...")
|
||||||
|
const since = await webmention.send("brainbaking.com", wmconfig)
|
||||||
|
console.log(` -- done`)
|
||||||
|
|
||||||
|
console.log("-- all done!")
|
||||||
|
})()
|
|
@ -11,6 +11,8 @@ const wmconfig = {
|
||||||
token: process.env.WEBMENTION_TOKEN
|
token: process.env.WEBMENTION_TOKEN
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const rootdir = `${__dirname}/../`;
|
||||||
|
|
||||||
(async function() {
|
(async function() {
|
||||||
// 1. parse Mastodon RSS feed
|
// 1. parse Mastodon RSS feed
|
||||||
// currently disabling notes, as after 3 months, I find these do not bring anything relevant to the table.
|
// currently disabling notes, as after 3 months, I find these do not bring anything relevant to the table.
|
||||||
|
@ -28,30 +30,25 @@ const wmconfig = {
|
||||||
// 2. update goodreads JS widget
|
// 2. update goodreads JS widget
|
||||||
console.log("2. Updating Goodreads Widget...")
|
console.log("2. Updating Goodreads Widget...")
|
||||||
const widget = await goodreads.createWidget("https://www.goodreads.com/review/grid_widget/5451893.Wouter's%20bookshelf:%20read?cover_size=medium&hide_link=&hide_title=&num_books=12&order=d&shelf=read&sort=date_added&widget_id=1496758344")
|
const widget = await goodreads.createWidget("https://www.goodreads.com/review/grid_widget/5451893.Wouter's%20bookshelf:%20read?cover_size=medium&hide_link=&hide_title=&num_books=12&order=d&shelf=read&sort=date_added&widget_id=1496758344")
|
||||||
await fsp.writeFile(`${__dirname}/static/js/goodreads.js`, widget.replace(/src=/g, "loading=\"lazy\" src="), 'utf-8')
|
await fsp.writeFile(`${rootdir}/static/js/goodreads.js`, widget.replace(/src=/g, "loading=\"lazy\" src="), 'utf-8')
|
||||||
|
|
||||||
// 3. build Lunr index
|
// 3. build Lunr index
|
||||||
console.log("3. Building lunr search index...")
|
console.log("3. Building lunr search index...")
|
||||||
const index = await lunr.buildIndex([`${__dirname}/content/post`])
|
const index = await lunr.buildIndex([`${rootdir}/content/post`])
|
||||||
await fsp.writeFile(`${__dirname}/static/js/brainbaking-post.json`, JSON.stringify(index), 'utf-8')
|
await fsp.writeFile(`${rootdir}/static/js/brainbaking-post.json`, JSON.stringify(index), 'utf-8')
|
||||||
|
|
||||||
// 4. get webmentions
|
// 4. get webmentions
|
||||||
console.log("4. Fetching webmentions...")
|
console.log("4. Fetching webmentions...")
|
||||||
const mentions = await webmention.getWebmentions("brainbaking.com", wmconfig)
|
const mentions = await webmention.getWebmentions("brainbaking.com", wmconfig)
|
||||||
const json = JSON.stringify(mentions, null, 4)
|
const json = JSON.stringify(mentions, null, 4)
|
||||||
await fsp.writeFile(`${__dirname}/data/webmentions.json`, json, 'utf-8')
|
await fsp.writeFile(`${rootdir}/data/webmentions.json`, json, 'utf-8')
|
||||||
|
|
||||||
// 5. send webmentions
|
// 5. generate youtube thumbnails
|
||||||
console.log("5. Sending webmentions...")
|
console.log("5. Generating YouTube thumbnails...")
|
||||||
const since = await webmention.send("brainbaking.com", wmconfig)
|
|
||||||
console.log(` -- done`)
|
|
||||||
|
|
||||||
// 6. generate youtube thumbnails
|
|
||||||
console.log("6. Generating YouTube thumbnails...")
|
|
||||||
await youtube.thumbify({
|
await youtube.thumbify({
|
||||||
postDir: `${__dirname}/content/post`,
|
postDir: `${rootdir}/content/post`,
|
||||||
downloadDir: `${__dirname}/static/img/yt`,
|
downloadDir: `${rootdir}/static/img/yt`,
|
||||||
overlayImg: `${__dirname}/play.png`
|
overlayImg: `${rootdir}/play.png`
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log("-- all done!")
|
console.log("-- all done!")
|
|
@ -13,7 +13,8 @@
|
||||||
"lodash": ">=4.17.21"
|
"lodash": ">=4.17.21"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"jamstack": "node jamstack-init.js"
|
"precommit": "node hooks/precommit.js",
|
||||||
|
"postdeploy": "node hooks/postdeploy.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
Loading…
Reference in New Issue