mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 01:53:30 +01:00
refactor: website facelift (#10823)
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
59
apps/website/src/util/shiki.bundle.ts
Normal file
59
apps/website/src/util/shiki.bundle.ts
Normal 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 };
|
||||
Reference in New Issue
Block a user