chore: data rewriting

This commit is contained in:
Cory Dransfeldt 2023-08-23 13:47:09 -07:00
parent 14e1945ba4
commit 8948ae8cb8
No known key found for this signature in database
4 changed files with 30 additions and 6 deletions

24
src/_data/fathom.js Normal file
View file

@ -0,0 +1,24 @@
const fs = require('fs')
const fetch = require('node-fetch')
module.exports = async function () {
const sourceUrl = 'https://cdn.usefathom.com/script.js'
fetch(sourceUrl)
.then((response) => response.text())
.then((sourceContent) => {
if (!sourceContent.includes('fathomScript.src.indexOf("cdn.usefathom.com")'))
throw new Error('Fathom script changed!')
const modifiedContent = sourceContent.replace(
'fathomScript.src.indexOf("cdn.usefathom.com")',
'fathomScript.src.indexOf("coryd.dev")'
)
const newFilePath = './_site/script.js'
fs.writeFile(newFilePath, modifiedContent, (err) => {
if (err) console.log(err)
})
})
.catch((err) => {
console.error('Error downloading the file:', err)
})
}