refactor(notes): use options object for renderCodeFile params
This commit is contained in:
@@ -14,8 +14,7 @@
|
|||||||
"fmt:check": "oxfmt --check",
|
"fmt:check": "oxfmt --check",
|
||||||
"prepare": "husky",
|
"prepare": "husky",
|
||||||
"theme:light": "esno _scripts/change-theme-light.ts",
|
"theme:light": "esno _scripts/change-theme-light.ts",
|
||||||
"theme:dark": "esno _scripts/change-theme-dark.ts",
|
"theme:dark": "esno _scripts/change-theme-dark.ts"
|
||||||
"generate-pwa-assets": "pwa-assets-generator"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@atproto/oauth-client-browser": "^0.3.41",
|
"@atproto/oauth-client-browser": "^0.3.41",
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ watch(
|
|||||||
}
|
}
|
||||||
const lang = p ? getFileLanguage(p) : null
|
const lang = p ? getFileLanguage(p) : null
|
||||||
const filename = p?.split("/").pop()
|
const filename = p?.split("/").pop()
|
||||||
const result = await renderCodeFile(raw, lang, filename)
|
const result = await renderCodeFile({ rawContent: raw, lang, filename })
|
||||||
if (rawContent.value === raw) {
|
if (rawContent.value === raw) {
|
||||||
displayedContent.value = result
|
displayedContent.value = result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,11 +164,15 @@ const renderMarkdown = (content: string, env?: Record<string, unknown>) => {
|
|||||||
return env ? md.render(content, env) : md.render(content)
|
return env ? md.render(content, env) : md.render(content)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const renderCodeFile = async (
|
export const renderCodeFile = async ({
|
||||||
rawContent: string,
|
rawContent,
|
||||||
lang: string | null,
|
lang,
|
||||||
|
filename
|
||||||
|
}: {
|
||||||
|
rawContent: string
|
||||||
|
lang: string | null
|
||||||
filename?: string
|
filename?: string
|
||||||
): Promise<string> => {
|
}): Promise<string> => {
|
||||||
await useShikiji()
|
await useShikiji()
|
||||||
const heading = filename ? `# ${filename}\n\n` : ""
|
const heading = filename ? `# ${filename}\n\n` : ""
|
||||||
if (lang !== null) {
|
if (lang !== null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user