0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/components/Prism.astro
Matthew Phillips 7240f0d677
Create a astro/components/ folder (#63)
This adds astro/components/ and moves the Prism.astro component into there. So to use in a project you can do:

```html
---
import Prism from 'astro/components/Prism.astro';
---

<Prism lang="html" code={`<html> ... </html>`}
```
2021-04-06 15:27:42 -04:00

16 lines
No EOL
336 B
Text

---
import Prism from 'prismjs';
import { addAstro } from '../astro-prism/index.mjs';
addAstro(Prism);
export let lang;
export let code;
const grammar = Prism.languages[lang];
let html = Prism.highlight(code, grammar, lang);
let className = `language-${lang}`;
---
<pre class={className}><code class={className}>{html}</code></pre>