feat(caddy): add Caddyfile TextMate grammar and enable Shiki syntax highlighting
Adds lib/grammars/caddyfile.json with scopes for directives, named-matchers (@prefix), placeholders, strings, and comments. Updates /caddy page to use createHighlighter with the local grammar instead of the nginx fallback. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0514810115
commit
93b50254e5
2 changed files with 92 additions and 5 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { redirect } from 'next/navigation'
|
||||
import Link from 'next/link'
|
||||
import { codeToHtml } from 'shiki'
|
||||
import { createHighlighter } from 'shiki'
|
||||
import caddyfileGrammar from '@/lib/grammars/caddyfile.json'
|
||||
import { getCurrentUser } from '@/lib/session'
|
||||
import { execAgent } from '@/lib/agent-client'
|
||||
import { parseCertList, type CertInfo } from '@/lib/parse-caddy'
|
||||
|
|
@ -16,10 +17,13 @@ export default async function CaddyPage() {
|
|||
let configError: string | null = null
|
||||
try {
|
||||
const raw = await execAgent('caddy_show_config')
|
||||
// shiki 1.29 bundelt geen caddyfile-grammar; nginx is syntactisch het
|
||||
// dichtst bij (directives + braces + reverse_proxy lijkt op locations)
|
||||
configHtml = await codeToHtml(raw || '# (empty)', {
|
||||
lang: 'nginx',
|
||||
const highlighter = await createHighlighter({
|
||||
themes: ['github-dark'],
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
langs: [caddyfileGrammar as any],
|
||||
})
|
||||
configHtml = highlighter.codeToHtml(raw || '# (empty)', {
|
||||
lang: 'caddyfile',
|
||||
theme: 'github-dark',
|
||||
})
|
||||
} catch (err) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue