Skip to content

Commit

Permalink
fix(markdownIt): 🐛 Resolving 'Top-level await is not available' Problem
Browse files Browse the repository at this point in the history
  • Loading branch information
bKoZii committed Sep 22, 2024
1 parent 63ffe91 commit 3210e66
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions composables/markdownIt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,25 @@ import 'markdown-it-github-alerts/styles/github-colors-light.css'
import 'markdown-it-github-alerts/styles/github-colors-dark-class.css'
import 'markdown-it-github-alerts/styles/github-base.css'

const { highlighter } = await getShikiHighlight()
const md = MarkdownIt({ linkify: true, typographer: true })
md.use(fromHighlighter(highlighter, { theme: 'aurora-x' }))
md.use(MarkdownItGitHubAlerts)
let md: MarkdownIt

async function setupMarkdownIt() {
const { highlighter } = await getShikiHighlight()
md = MarkdownIt({ linkify: true, typographer: true })
md.use(fromHighlighter(highlighter, { theme: 'aurora-x' }))
md.use(MarkdownItGitHubAlerts)
}

setupMarkdownIt()

export default defineNuxtPlugin(() => {
return {
provide: {
markdownIt: (content: string) => md.render(content)
}
}
})

export const useMarkdownIt = async (content: string) => {
return await md.render(content)
return md.render(content)
}

1 comment on commit 3210e66

@vercel
Copy link

@vercel vercel bot commented on 3210e66 Sep 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.