Skip to content

Commit

Permalink
fix(website): use correct lang for code highlightning
Browse files Browse the repository at this point in the history
  • Loading branch information
cschroeter committed Nov 30, 2024
1 parent fd08383 commit 91576d6
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion website/src/components/docs/component-playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const ComponentPlayground = async () => {
}),
),
Effect.flatMap((code) =>
Effect.promise(() => highlight(code, framework)).pipe(
Effect.promise(() => highlight(code, framework === 'vue' ? 'vue' : 'tsx')).pipe(
Effect.map((html) => ({
code,
html,
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/docs/installation-guide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const InstallationGuide = async () => {
const { component } = getServerContext()

const code = `npx @park-ui/cli components add ${component}`
const html = await highlight(code)
const html = await highlight(code, 'bash')

return (
<Tabs.Root defaultValue="cli">
Expand Down
4 changes: 3 additions & 1 deletion website/src/components/docs/manual-installation-guide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export const ManualIntallationGuide = async () => {
pipe(
Effect.forEach(component.variants, (variant) =>
pipe(
Effect.promise(() => highlight(variant.content)),
Effect.promise(() =>
highlight(variant.content, framework === 'vue' ? 'vue' : 'tsx'),
),
Effect.map((html) => ({
file: variant.file,
label: framework,
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/docs/recipe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const Recipe = async () => {
}),
Effect.catchAll(() => Effect.succeed('Not yet available')),
Effect.flatMap((code) =>
Effect.promise(() => highlight(code)).pipe(
Effect.promise(() => highlight(code, 'ts')).pipe(
Effect.map((html) => ({
code,
html,
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/theming/theme-config-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const ThemeConfigDialog = () => {

useEffect(() => {
const highlightConfig = async () => {
const html = await highlight(getConfig())
const html = await highlight(getConfig(), 'ts')
setHtml(html)
}
highlightConfig()
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/ui/pre.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const Pre = async (props: PropsWithChildren) => {
const rawCode = props.children?.props.children.toString() as string

const hasPreview = rawCode.startsWith('// live')
const html = await highlight(rawCode)
const html = await highlight(rawCode, lang)
const code = rawCode.replace('// live', '').trim()

return (
Expand Down
6 changes: 3 additions & 3 deletions website/src/lib/shiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { createHighlighter } from 'shiki'

const highlighter = createHighlighter({
themes: ['github-dark-default'],
langs: ['vue', 'tsx'],
langs: ['vue', 'tsx', 'bash', 'json', 'txt'],
})

export const highlight = async (code: string, framework?: string) =>
export const highlight = async (code: string, lang: string) =>
(await highlighter).codeToHtml(code, {
lang: framework === 'vue' ? 'vue' : 'tsx',
lang,
theme: 'github-dark-default',
})

0 comments on commit 91576d6

Please sign in to comment.