feat: add JSON-LD structured data to homepage and fix CSP nonce hook …#3150
Conversation
…stripping script attributes
|
hii @sydseter, Take a look at this, whenever you have time. |
|
the nonce in the hook is a placeholder. The Cloudlfare nonce worker https://github.com/OWASP/cornucopia/blob/master/cornucopia.owasp.org/script/nonce-worker.js uses the placeholder nonce that the hook injects into every script tag and replaces it with a unique nonce. This happens begore the page is served by Cloudflare. |
There was a problem hiding this comment.
Pull request overview
Adds SEO-focused structured data to the SvelteKit homepage and updates the server-side nonce injection so JSON-LD <script> tags keep required attributes (e.g., type="application/ld+json").
Changes:
- Add Organization + WebSite JSON-LD graph to the homepage
<head>. - Update
hooks.server.jsscript-tag nonce injection to preserve existing<script>attributes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
cornucopia.owasp.org/src/routes/+page.svelte |
Adds JSON-LD structured data to the homepage head for SEO. |
cornucopia.owasp.org/src/hooks.server.js |
Adjusts nonce injection regex so existing <script> attributes are not wiped. |
|
Thanks for explaining! i missed that point |
|
hii @sydseter done! |
Description
Fixes #2194
Added Organization + WebSite JSON-LD structured data to the homepage
for SEO. Validated on schema.org and no errors were there
While testing I noticed the CSP nonce hook in hooks.server.js was wiping all attributes from every script tag sitewide, not just injecting the nonce. The JSON-LD tag needs type="application/ld+json" to work, so I fixed the regex to preserve existing attributes.
AI Tool Disclosure
[e.g. GitHub CoPilot, ChatGPT, JetBrains Junie etc.][e.g. GPT-4.1, Claude Haiku 4.5, Gemini 2.5 Pro etc.][Summarize the key prompts or instructions given to the AI tools]Affirmation