refactor: website facelift (#10823)

This commit is contained in:
Noel
2025-04-10 22:02:37 +02:00
committed by GitHub
parent 1fe53c7ca2
commit 2e3bc69602
80 changed files with 6136 additions and 2529 deletions

View File

@@ -27,10 +27,10 @@ export async function fetchDependencies({
}
try {
const isMainVersion = version === 'main';
const isMain = version === 'main';
const fileContent = await fetch(
`${process.env.BLOB_STORAGE_URL}/rewrite/${packageName}/${version}.dependencies.api.json`,
{ next: isMainVersion ? { revalidate: 0 } : { revalidate: 604_800 } },
{ next: { revalidate: isMain ? 0 : 604_800 } },
);
const parsedDependencies = await fileContent.json();

View File

@@ -25,10 +25,10 @@ export async function fetchNode({
return JSON.parse(fileContent);
}
const isMainVersion = version === 'main';
const isMain = version === 'main';
const fileContent = await fetch(
`${process.env.BLOB_STORAGE_URL}/rewrite/${packageName}/${version}.${normalizeItem}.api.json`,
{ next: isMainVersion ? { revalidate: 0 } : { revalidate: 604_800 } },
{ next: { revalidate: isMain ? 0 : 604_800 } },
);
if (!fileContent.ok) {

View File

@@ -18,10 +18,12 @@ export async function fetchSitemap({
return JSON.parse(fileContent);
}
const isMainVersion = version === 'main';
const isMain = version === 'main';
const fileContent = await fetch(
`${process.env.BLOB_STORAGE_URL}/rewrite/${packageName}/${version}.sitemap.api.json`,
{ next: isMainVersion ? { revalidate: 0 } : { revalidate: 604_800 } },
{
next: { revalidate: isMain ? 0 : 604_800 },
},
);
if (!fileContent.ok) {

View File

@@ -0,0 +1,59 @@
/* Generate by @shikijs/codegen */
import type {
DynamicImportLanguageRegistration,
DynamicImportThemeRegistration,
HighlighterGeneric,
} from 'shiki/types';
import { createSingletonShorthands, createdBundledHighlighter } from 'shiki/core';
import { createJavaScriptRegexEngine } from 'shiki/engine-javascript.mjs';
type BundledLanguage = 'typescript' | 'ts' | 'javascript' | 'js' | 'shellscript' | 'bash' | 'sh' | 'shell' | 'zsh';
type BundledTheme = 'github-light' | 'github-dark-dimmed';
type Highlighter = HighlighterGeneric<BundledLanguage, BundledTheme>;
const bundledLanguages = {
typescript: () => import('shiki/langs/typescript.mjs'),
ts: () => import('shiki/langs/typescript.mjs'),
javascript: () => import('shiki/langs/javascript.mjs'),
js: () => import('shiki/langs/javascript.mjs'),
shellscript: () => import('shiki/langs/shellscript.mjs'),
bash: () => import('shiki/langs/shellscript.mjs'),
sh: () => import('shiki/langs/shellscript.mjs'),
shell: () => import('shiki/langs/shellscript.mjs'),
zsh: () => import('shiki/langs/shellscript.mjs'),
} as Record<BundledLanguage, DynamicImportLanguageRegistration>;
const bundledThemes = {
'github-light': () => import('shiki/themes/github-light.mjs'),
'github-dark-dimmed': () => import('shiki/themes/github-dark-dimmed.mjs'),
} as Record<BundledTheme, DynamicImportThemeRegistration>;
const createHighlighter = /* @__PURE__ */ createdBundledHighlighter<BundledLanguage, BundledTheme>({
langs: bundledLanguages,
themes: bundledThemes,
engine: () => createJavaScriptRegexEngine(),
});
const {
codeToHtml,
codeToHast,
codeToTokensBase,
codeToTokens,
codeToTokensWithThemes,
getSingletonHighlighter,
getLastGrammarState,
} = /* @__PURE__ */ createSingletonShorthands<BundledLanguage, BundledTheme>(createHighlighter);
export {
bundledLanguages,
bundledThemes,
codeToHast,
codeToHtml,
codeToTokens,
codeToTokensBase,
codeToTokensWithThemes,
createHighlighter,
getLastGrammarState,
getSingletonHighlighter,
};
export type { BundledLanguage, BundledTheme, Highlighter };