Code Block Examples

50 words
1 minute
Code Block Examples

This page checks code block rendering in English pages.

TypeScript#

type SupportedLang = "zh" | "en";
function withLangPrefix(pathname: string, lang: SupportedLang) {
const stripped = pathname.replace(/^\/(zh|en)(?=\/|$)/, "");
return `/${lang}${stripped || "/"}`;
}
console.log(withLangPrefix("/posts/demo/", "en"));

PowerShell#

Terminal window
npm run type-check
npx astro check
npm run build

Bash#

Terminal window
pnpm install
pnpm dev

JSON#

{
"language": "en",
"route": "/en/posts/markdown/code-examples/",
"pagefind": true
}

Support & Share

If this article helped you, please share or support!

Sponsor
Code Block Examples
https://docs.bingyun.vip/en/posts/markdown/code-examples/
Author
BingYun
Published at
1970-01-03
License
CC BY-NC-SA 4.0

Comments

Profile image of BingYun
BingYun
Welcome to BingYun Docs!
Categories
Tags
Site Statistics
Posts
12
Categories
2
Tags
5
Total Words
10,808
Running Days
0 days
Last Activity
0 days ago

Table of Contents