Skip to content

Commit

Permalink
re-patch post rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 committed Jul 11, 2024
1 parent 7ea44f7 commit feb20bc
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 7 deletions.
51 changes: 51 additions & 0 deletions patches/@greenwood+cli+0.30.0-alpha.4.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
diff --git a/node_modules/@greenwood/cli/src/lib/layout-utils.js b/node_modules/@greenwood/cli/src/lib/layout-utils.js
index e397396..8dbf281 100644
--- a/node_modules/@greenwood/cli/src/lib/layout-utils.js
+++ b/node_modules/@greenwood/cli/src/lib/layout-utils.js
@@ -227,15 +227,29 @@ async function getAppLayout(pageLayoutContents, compilation, customImports = [],
const mergedStyles = [
...appRoot.querySelectorAll('head style'),
...[...(pageRoot && pageRoot.querySelectorAll('head style')) || []],
- ...customImports.filter(resource => resource.split('.').pop() === 'css')
- .map(resource => `<link rel="stylesheet" href="${resource}"></link>`)
+ ...customImports.filter(resource => resource.split(' ')[0].split('.').pop() === 'css')
+ .map((resource) => {
+ const [href, ...attributes] = resource.split(' ');
+ const attrs = attributes?.length > 0
+ ? attributes.join(' ')
+ : '';
+
+ return `<link rel="stylesheet" href="${href}" ${attrs}></link>`;
+ })
].join('\n');

const mergedScripts = [
...appRoot.querySelectorAll('head script'),
...[...(pageRoot && pageRoot.querySelectorAll('head script')) || []],
- ...customImports.filter(resource => resource.split('.').pop() === 'js')
- .map(resource => `<script src="${resource}" type="module"></script>`)
+ ...customImports.filter(resource => resource.split(' ')[0].split('.').pop() === 'js')
+ .map((resource) => {
+ const [src, ...attributes] = resource.split(' ');
+ const attrs = attributes?.length > 0
+ ? attributes.join(' ')
+ : '';
+
+ return `<script src="${src}" ${attrs}></script>`;
+ })
].join('\n');

const finalBody = pageLayoutContents
diff --git a/node_modules/@greenwood/cli/src/lifecycles/bundle.js b/node_modules/@greenwood/cli/src/lifecycles/bundle.js
index 21636a9..7a01fe0 100644
--- a/node_modules/@greenwood/cli/src/lifecycles/bundle.js
+++ b/node_modules/@greenwood/cli/src/lifecycles/bundle.js
@@ -105,7 +105,7 @@ async function optimizeStaticPages(compilation, plugins) {
}

// clean up optimization markers
- const body = (await response.text()).replace(/data-gwd-opt=".*[a-z]"/g, '');
+ const body = (await response.text()).replace(/data-gwd-opt=".*?[a-z]"/g, '');

await fs.writeFile(new URL(`.${outputPath}`, outputDir), body);
})
14 changes: 7 additions & 7 deletions src/pages/index.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
imports:
- ../components/latest-post/latest-post.js data-gwd-opt="static"
- ../components/hero-banner/hero-banner.js data-gwd-opt="static"
- ../components/walkthrough/walkthrough.js
- ../components/why-greenwood/why-greenwood.js data-gwd-opt="static"
- ../components/run-anywhere/run-anywhere.js data-gwd-opt="static"
- ../components/build-with-friends/build-with-friends.js data-gwd-opt="static"
- ../components/get-started/get-started.js data-gwd-opt="static"
- ../components/latest-post/latest-post.js data-gwd-opt="static" type="module"
- ../components/hero-banner/hero-banner.js data-gwd-opt="static" type="module"
- ../components/walkthrough/walkthrough.js type="module"
- ../components/why-greenwood/why-greenwood.js data-gwd-opt="static" type="module"
- ../components/run-anywhere/run-anywhere.js data-gwd-opt="static" type="module"
- ../components/build-with-friends/build-with-friends.js data-gwd-opt="static" type="module"
- ../components/get-started/get-started.js data-gwd-opt="static" type="module"
- ../styles/home.css
---

Expand Down

0 comments on commit feb20bc

Please sign in to comment.