Skip to content

Commit

Permalink
Add load-bearing Hugo stubs 🙃🤷‍♂️
Browse files Browse the repository at this point in the history
  • Loading branch information
bglw committed May 12, 2023
1 parent e51ddc4 commit 4e5d03f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion javascript-modules/engines/hugo-engine/lib/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class Engine {
this.key = 'hugo';
this.name = options.name;
this.files = options.files;
this.origin = (typeof document !== 'undefined' && document.currentScript?.src) || `/bookshop.js`;
this.origin = (typeof document === 'undefined' ? '' : document.currentScript?.src) || `/bookshop.js`;
this.synthetic = options.synthetic ?? false;

if (!this.synthetic) {
Expand Down Expand Up @@ -81,6 +81,20 @@ export class Engine {

const componentSuccess = window["writeHugoFiles"](JSON.stringify(mappedFiles));
const templateSuccess = window["writeHugoFiles"](JSON.stringify(templates));

// BIG OL' TODO: Writing these files ahead of render() seems to be load-bearing,
// which doesn't yet make sense to me.
// If these files are created for the first time in render(), the site doesn't
// appear to build (need to extract some logs from hugo to determine why).
// Perplexingly, writing then building in eval() appears to have been working
// fine in the same case.
// My suspicion would be something around our changeEvents() handling
// in the Hugo builder, but I don't know why that wouldn't affect eval()... 🤷‍♂️
// For now, the load-bearing stubs will live in this Hugo initialization.
window.writeHugoFiles(JSON.stringify({
"layouts/index.html": "Uninitialized Layout",
"content/_index.md": "{ \”initialized\": false }\n"
}));
}

async initializeLocalCompressedHugo() {
Expand Down

0 comments on commit 4e5d03f

Please sign in to comment.