diff --git a/examples/with-markdown/src/pages/prism.astro b/examples/with-markdown/src/pages/prism.astro new file mode 100644 index 0000000000000..9d7c87c41b9bb --- /dev/null +++ b/examples/with-markdown/src/pages/prism.astro @@ -0,0 +1,5 @@ +--- +import {Prism} from '@astrojs/prism/components'; +--- + + \ No newline at end of file diff --git a/packages/astro/components/Prism.astro b/packages/astro/components/Prism.astro deleted file mode 100644 index 5f92b1f667e4f..0000000000000 --- a/packages/astro/components/Prism.astro +++ /dev/null @@ -1,49 +0,0 @@ ---- -import Prism from 'prismjs'; -import { addAstro } from '@astrojs/prism'; -import loadLanguages from 'prismjs/components/index.js'; - -export interface Props { - class?: string; - lang?: string; - code: string; -} - -const { class: className, lang, code } = Astro.props as Props; - -let classLanguage = `language-${lang}`; - -const languageMap = new Map([['ts', 'typescript']]); - -if (lang == null) { - console.warn('Prism.astro: No language provided.'); -} - -const ensureLoaded = (lang) => { - if (lang && !Prism.languages[lang]) { - loadLanguages([lang]); - } -}; - -if (languageMap.has(lang)) { - ensureLoaded(languageMap.get(lang)); -} else if (lang === 'astro') { - ensureLoaded('typescript'); - addAstro(Prism); -} else { - ensureLoaded('markup-templating'); // Prism expects this to exist for a number of other langs - ensureLoaded(lang); -} - -if (lang && !Prism.languages[lang]) { - console.warn(`Unable to load the language: ${lang}`); -} - -const grammar = Prism.languages[lang]; -let html = code; -if (grammar) { - html = Prism.highlight(code, grammar, lang); -} ---- - -
diff --git a/packages/astro/components/index.js b/packages/astro/components/index.js index 8b19c7d1f2c3e..b16d8983ac480 100644 --- a/packages/astro/components/index.js +++ b/packages/astro/components/index.js @@ -1,4 +1,3 @@ export { default as Code } from './Code.astro'; export { default as Debug } from './Debug.astro'; export { default as Markdown } from './Markdown.astro'; -export { default as Prism } from './Prism.astro';