chore: data rewriting
This commit is contained in:
parent
14e1945ba4
commit
8948ae8cb8
4 changed files with 30 additions and 6 deletions
24
src/_data/fathom.js
Normal file
24
src/_data/fathom.js
Normal 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)
|
||||
})
|
||||
}
|
|
@ -56,7 +56,7 @@
|
|||
{% jsonLd meta, type, tags %}
|
||||
</script>
|
||||
<script
|
||||
src="https://cdn.usefathom.com/script.js"
|
||||
src="{{ site.url }}/script.js?v={% version %}"
|
||||
data-site="RBCOWZTA"
|
||||
defer></script>
|
||||
<noscript>
|
||||
|
|
Reference in a new issue