Skip to content

Commit

Permalink
try this
Browse files Browse the repository at this point in the history
  • Loading branch information
MattIPv4 committed Sep 13, 2019
1 parent 2cab7af commit 3e7c02e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions build/buildTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ const index = async (file, out) => {
const post = posthtml(plugins)

// Process
const result = await post.process(source)
const html = (await post.process(source)).html

// Remove comments before HTML
const result = html.replace(/^(<!--.+?-->[\w\n]*)*/gms, '')

// Export
fs.writeFileSync(Path.join(__dirname, '..', out), result.html, { flag: 'w+' })
fs.writeFileSync(Path.join(__dirname, '..', out), result, { flag: 'w+' })
console.log(`...build successfully, saved to ${out}`)
}

Expand Down
12 changes: 9 additions & 3 deletions build/fetchTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const main = async () => {
let rawHTML = await res.text()

// Parse
const { document } = (new JSDOM(rawHTML)).window
const dom = new JSDOM(rawHTML)
const { document } = dom.window
const nav = document.querySelector('nav.do_nav')

// Nuke top log in button
Expand Down Expand Up @@ -58,8 +59,13 @@ const main = async () => {
}
})

// Inject charset
const charset = document.createElement('meta')
charset.setAttribute('charset', 'utf8')
document.head.insertBefore(charset, document.head.firstChild)

// Convert back to raw
rawHTML = document.documentElement.innerHTML
rawHTML = dom.serialize()

// Inject title block
rawHTML = rawHTML.replace(/<title>(.+?)<\/title>/, '<title><block name="title"></block>$1</title>')
Expand All @@ -72,7 +78,7 @@ const main = async () => {
'<block name="content"></block><div class="clearfix"></div>')

// Inject last fetch comment
rawHTML = rawHTML.replace('<head>', `<head><!-- Last fetch from www.digitalocean.com @ ${(new Date()).toISOString()} -->`)
rawHTML = rawHTML.replace('<head>', `<!-- Last fetch from www.digitalocean.com @ ${(new Date()).toISOString()} -->\n<head>`)

// Export
fs.writeFileSync(`${__dirname}/base.html`, rawHTML, { flag: 'w+' })
Expand Down

1 comment on commit 3e7c02e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been deployed to DigitalOcean Spaces for easy reviewing.

dns-tool spf-explainer

Please sign in to comment.