Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proof of concept home page storyboarding #9

Closed
wants to merge 11 commits into from
61 changes: 61 additions & 0 deletions greenwood.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { ResourceInterface } from "@greenwood/cli/src/lib/resource-interface.js";

class CodeBlockComponentEscapingResource extends ResourceInterface {
async shouldIntercept(url) {
const { pathname } = url;

return this.compilation.graph.find(node => node.route === pathname);
}

async intercept(url, request, response) {
let html = await response.text();
// TODO handle attributes and classnames
// cant handle more than one block
const blocks = html.match(/<www-code-block>(.*.)<\/www-code-block>/gs);

console.log({ blocks });
if (blocks) {
blocks.forEach((block) => {
console.log({ block })
const contents = block
.replace('<www-code-block>', '')
.replace('</www-code-block>', '')
console.log({ contents })
html = html.replace(contents, contents
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
)
})

console.log({ html });
}

return new Response(html);
}
}

export default {
plugins: [{
// type: 'resource',
// name: 'plugin-resource-code-block-escaping',
// provider: (compilation) => new CodeBlockComponentEscapingResource(compilation)
// }, {
// TODO get this functionality from Greenwood itself
// https://github.com/ProjectEvergreen/greenwood/issues/1199
type: 'copy',
name: 'plugin-geist-font',
provider: (compilation) => {
const { outputDir, projectDirectory } = compilation.context;

return [{
from: new URL('./node_modules/geist/dist/fonts/', projectDirectory),
to: new URL('./node_modules/geist/dist/fonts/', outputDir)
}];
}
}],
markdown: {
plugins: [
'@mapbox/rehype-prism'
]
}
}
115 changes: 115 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@
"dev": "greenwood develop",
"serve": "npm run clean && npm run build && greenwood serve"
},
"dependencies": {
"geist": "^1.2.0",
"prismjs": "^1.21.0"
},
"devDependencies": {
"@greenwood/cli": "^0.29.0",
"@mapbox/rehype-prism": "^0.5.0",
"rimraf": "^5.0.5"
}
}
12 changes: 0 additions & 12 deletions src/pages/index.html

This file was deleted.

Loading