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

frontmatter content breaking graph data parsing in SSR pages #1351

Closed
thescientist13 opened this issue Dec 19, 2024 · 0 comments · Fixed by #1362
Closed

frontmatter content breaking graph data parsing in SSR pages #1351

thescientist13 opened this issue Dec 19, 2024 · 0 comments · Fixed by #1362
Assignees
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented Dec 19, 2024

Type of Change

Bug

Summary

Working on this project being migrated to Greenwood a run into a number of issues with certain frontmatter content blowing up SSR pages, as it was breaking the JSON.stringify call that happens in SSR pages, that allows the graph to be inlined.

Cases found

Apostrophes

This breaks at build / bundle time for the SSR page

---
title: The thing's that happened to me
---
  Error [RollupError]: Expression expected
      at getRollupError (file:///Users/owenbuckley/Workspace/github/greenwood-lit-ssr/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/parseAst.js:396:41)
      at convertProgram (file:///Users/owenbuckley/Workspace/github/greenwood-lit-ssr/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/parseAst.js:1084:26)
      at Object.parseAst [as parse] (file:///Users/owenbuckley/Workspace/github/greenwood-lit-ssr/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/parseAst.js:2069:87)
      at Object.transform (file:///Users/owenbuckley/Workspace/github/greenwood-lit-ssr/node_modules/.pnpm/@[email protected]/node_modules/@greenwood/cli/src/config/rollup.config.js:284:24)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async transform (file:///Users/owenbuckley/Workspace/github/greenwood-lit-ssr/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:19663:16)
      at async ModuleLoader.addModuleSource (file:///Users/owenbuckley/Workspace/github/greenwood-lit-ssr/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:19879:36) {
    code: 'PLUGIN_ERROR',
    pos: 717,
    pluginCode: 'PARSE_ERROR',
    plugin: 'greenwood-import-meta-url',
    hook: 'transform',
    id: '/Users/owenbuckley/Workspace/github/greenwood-lit-ssr/.greenwood/products.ts'
  }
  

Double Quotes in Frontmatter Imports

This happens at runtime on load of an SSR page

---
imports:
  - /components/my-component.ts type="module"
---
  SyntaxError [Error]: Unexpected token m in JSON at position 151
      at JSON.parse ()
      at handler (file:///Users/owenbuckley/Workspace/github/greenwood-lit-ssr/public/products.route.js:9731:30)
      at executeModule (file:///Users/owenbuckley/Workspace/github/greenwood-lit-ssr/node_modules/.pnpm/@[email protected]/node_modules/@greenwood/cli/src/lib/ssr-route-worker-isolation-mode.js:6:26)
      at async MessagePort. (file:///Users/owenbuckley/Workspace/github/greenwood-lit-ssr/node_modules/.pnpm/@[email protected]/node_modules/@greenwood/cli/src/lib/ssr-route-worker-isolation-mode.js:13:3)
  

Line Breaks

This happens at runtime on load of an SSR page

---
title: |
  Foo, Bar, Baz

  SyntaxError [Error]: Unexpected token 
   in JSON at position 62
      at JSON.parse ()
      at handler (file:///Users/owenbuckley/Workspace/github/greenwood-lit-ssr/public/products.route.js:9731:30)
      at executeModule (file:///Users/owenbuckley/Workspace/github/greenwood-lit-ssr/node_modules/.pnpm/@[email protected]/node_modules/@greenwood/cli/src/lib/ssr-route-worker-isolation-mode.js:6:26)
      at async MessagePort. (file:///Users/owenbuckley/Workspace/github/greenwood-lit-ssr/node_modules/.pnpm/@[email protected]/node_modules/@greenwood/cli/src/lib/ssr-route-worker-isolation-mode.js:13:3)
  

Nested Frontmatter

Hmm, can not reproduce in isolation?

---
sidebar:
  order: 1
---
---
<!-- but this works -->
sidebar:
  - order: 1
---

Details

For a few of these, I'm not sure if the syntax is valid, or would otherwise have to figure out how they are parsed

  • line breaks, e.g. title
  • nested frontmatter

I also wonder if we should also be calling pruneGraph in these cases as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
1 participant