diff --git a/packages/cli/src/lib/layout-utils.js b/packages/cli/src/lib/layout-utils.js index e39739676..8dbf28197 100644 --- a/packages/cli/src/lib/layout-utils.js +++ b/packages/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 => ``) + ...customImports.filter(resource => resource.split(' ')[0].split('.').pop() === 'css') + .map((resource) => { + const [href, ...attributes] = resource.split(' '); + const attrs = attributes?.length > 0 + ? attributes.join(' ') + : ''; + + return ``; + }) ].join('\n'); const mergedScripts = [ ...appRoot.querySelectorAll('head script'), ...[...(pageRoot && pageRoot.querySelectorAll('head script')) || []], - ...customImports.filter(resource => resource.split('.').pop() === 'js') - .map(resource => ``) + ...customImports.filter(resource => resource.split(' ')[0].split('.').pop() === 'js') + .map((resource) => { + const [src, ...attributes] = resource.split(' '); + const attrs = attributes?.length > 0 + ? attributes.join(' ') + : ''; + + return ``; + }) ].join('\n'); const finalBody = pageLayoutContents diff --git a/packages/cli/src/lifecycles/bundle.js b/packages/cli/src/lifecycles/bundle.js index 4ed4cb218..9c963f786 100644 --- a/packages/cli/src/lifecycles/bundle.js +++ b/packages/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); }) diff --git a/packages/cli/test/cases/build.default.workspace-frontmatter-imports/build.default.workspace-frontmatter-imports.spec.js b/packages/cli/test/cases/build.default.workspace-frontmatter-imports/build.default.workspace-frontmatter-imports.spec.js index d5f789371..d7c39f9f3 100644 --- a/packages/cli/test/cases/build.default.workspace-frontmatter-imports/build.default.workspace-frontmatter-imports.spec.js +++ b/packages/cli/test/cases/build.default.workspace-frontmatter-imports/build.default.workspace-frontmatter-imports.spec.js @@ -110,6 +110,16 @@ describe('Build Greenwood With: ', function() { it('should output a heading tag from the custom element', function() { expect(html).to.contain('

My Counter

'); }); + + it('should have expected attributes on the `` tag from frontmatter imports', async function() { + const link = Array.from(dom.window.document + .querySelectorAll('head link')) + .find(link => link.getAttribute('href')?.startsWith('/components/counter/')); + + expect(link.getAttribute('data-gwd-opt')).to.equal(null); + expect(link.getAttribute('foo')).to.equal('bar'); + expect(link.getAttribute('baz')).to.equal('bar'); + }); }); describe('Custom Multihyphen component', () => { @@ -127,6 +137,15 @@ describe('Build Greenwood With: ', function() { it('should have the expected prerendered content', function() { expect(html).to.contain('I have multiple hyphens in my tag name!'); }); + + it('should have expected attributes on the ` + ```