withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.82k stars 2.49k forks source link

🐛 BUG: Parse error when using Remote Markdown #930

Closed Tc-001 closed 3 years ago

Tc-001 commented 3 years ago

What package manager are you using?

npm

What operating system are you using?

Linux

Describe the Bug

Using <Markdown content={content} /> will cause an error when rendering.

Expected behavior shown in docs: https://docs.astro.build/guides/markdown-content#remote-markdown

Steps to Reproduce

  1. npm init astro using template Starter Kit (Generic)
  2. Replace index.astro with:
    
    ---
    import { Markdown } from 'astro/components';
    const content = "This is a test"
    ---
3. Attempt to view the page  with `npm start`
4. Error! Page shows a 500 screen "Astro had some trouble loading this page."

Error: Parse error @:1:1 at parse (/path/to/project/node_modules/snowpack/node_modules/es-module-lexer/dist/lexer.cjs:1:402) at scanCodeImportsExports (/path/to/project/node_modules/snowpack/lib/cjs/rewrite-imports.js:21:29) at transformEsmImports (/path/to/project/node_modules/snowpack/lib/cjs/rewrite-imports.js:37:27) at Object.transformFileImports (/path/to/project/node_modules/snowpack/lib/cjs/rewrite-imports.js:108:16) at FileBuilder.resolveImports (/path/to/project/node_modules/snowpack/lib/cjs/build/file-builder.js:116:48) at async Object.loadUrl (/path/to/project/node_modules/snowpack/lib/cjs/commands/dev.js:640:39) at async load (/path/to/project/node_modules/snowpack/lib/cjs/commands/dev.js:217:28) at async /path/to/project/node_modules/snowpack/lib/cjs/ssr-loader/index.js:60:28 at async Object.importModule (/path/to/project/node_modules/snowpack/lib/cjs/ssr-loader/index.js:165:26) at async load (file:///path/to/project/node_modules/astro/dist/runtime.js:76:17) at async Server. (file:///path/to/project/node_modules/astro/dist/dev.js:21:20)



Expected result is for the page to be displayed with the text. 

That can be achieved with `<Markdown>This is a test</Markdown>`, but this approach removes programmatically setting the value of it.

### Link to Minimal Reproducible Example (Optional)

_No response_
amatiasq commented 3 years ago

Same bug as https://github.com/snowpackjs/astro/issues/933

matthewp commented 3 years ago

Closing as a duplicate