mirror of
https://github.com/prdlk/leetcode.git
synced 2026-11-02 13:12:44 +00:00
feat(config): add appendix redirects and navigation entries, remove list schema, update comments
This commit is contained in:
1 parent
88c0c9b898
commit
937266b629
1 file changed
+24
-17
+24
-17
@@ -1,6 +1,7 @@
|
|||||||
import { defineConfig } from "blume";
|
import { defineConfig } from "blume";
|
||||||
import type { StandardSchema } from "blume/core/standard-schema.ts";
|
import type { StandardSchema } from "blume/core/standard-schema.ts";
|
||||||
import { filesystem } from "blume/sources";
|
import { filesystem } from "blume/sources";
|
||||||
|
import { APPENDIX } from "./appendix";
|
||||||
import redirects from "./redirects";
|
import redirects from "./redirects";
|
||||||
|
|
||||||
// Blume's defaults (`inter`, `ibm-plex-mono`) are fetched from fonts.gstatic.com
|
// Blume's defaults (`inter`, `ibm-plex-mono`) are fetched from fonts.gstatic.com
|
||||||
@@ -36,10 +37,9 @@ const plexMono = {
|
|||||||
* components/ProblemBadges.astro. Problem pages: `topics:` is LeetCode's topic
|
* components/ProblemBadges.astro. Problem pages: `topics:` is LeetCode's topic
|
||||||
* tags and `issue:` the problem's GitHub issue URL (both written by
|
* tags and `issue:` the problem's GitHub issue URL (both written by
|
||||||
* apps/cli/sync.ts), `video:` the NeetCode walkthrough's
|
* apps/cli/sync.ts), `video:` the NeetCode walkthrough's
|
||||||
* YouTube id (apps/cli/videos.ts). Guide pages (content/appendix/, created by
|
* YouTube id (apps/cli/videos.ts). Blume rejects undeclared keys and takes
|
||||||
* sync): `list:` is the tag's LeetCode problem list. Blume rejects undeclared
|
* any Standard Schema; these are hand-rolled so the docs workspace needs no
|
||||||
* keys and takes any Standard Schema; these are hand-rolled so the docs
|
* zod. All optional — every other page carries none.
|
||||||
* workspace needs no zod. All optional — every other page carries none.
|
|
||||||
*/
|
*/
|
||||||
const optional = <T>(
|
const optional = <T>(
|
||||||
message: string,
|
message: string,
|
||||||
@@ -68,12 +68,6 @@ const videoSchema = optional(
|
|||||||
(value): value is string =>
|
(value): value is string =>
|
||||||
typeof value === "string" && /^[\w-]{11}$/.test(value),
|
typeof value === "string" && /^[\w-]{11}$/.test(value),
|
||||||
);
|
);
|
||||||
const listSchema = optional(
|
|
||||||
"expected a https://leetcode.com/problem-list/<slug>/ URL",
|
|
||||||
(value): value is string =>
|
|
||||||
typeof value === "string" &&
|
|
||||||
/^https:\/\/leetcode\.com\/problem-list\/[\w-]+\/$/.test(value),
|
|
||||||
);
|
|
||||||
const issueSchema = optional(
|
const issueSchema = optional(
|
||||||
"expected a https://github.com/<owner>/<repo>/issues/<n> URL",
|
"expected a https://github.com/<owner>/<repo>/issues/<n> URL",
|
||||||
(value): value is string =>
|
(value): value is string =>
|
||||||
@@ -93,12 +87,20 @@ export default defineConfig({
|
|||||||
repo: "leetcode",
|
repo: "leetcode",
|
||||||
},
|
},
|
||||||
lastModified: "git",
|
lastModified: "git",
|
||||||
redirects,
|
// Sync's `/<num>` short links, then the Appendix's former per-term pages
|
||||||
|
// (`/appendix/<slug>`, published until the glossary became one page) onto
|
||||||
|
// their cards, so old links and search results still land.
|
||||||
|
redirects: [
|
||||||
|
...redirects,
|
||||||
|
...Object.keys(APPENDIX).map((slug) => ({
|
||||||
|
from: `/appendix/${slug}`,
|
||||||
|
to: `/appendix#${slug}`,
|
||||||
|
})),
|
||||||
|
],
|
||||||
frontmatter: {
|
frontmatter: {
|
||||||
extend: {
|
extend: {
|
||||||
topics: topicsSchema,
|
topics: topicsSchema,
|
||||||
video: videoSchema,
|
video: videoSchema,
|
||||||
list: listSchema,
|
|
||||||
issue: issueSchema,
|
issue: issueSchema,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -125,9 +127,10 @@ export default defineConfig({
|
|||||||
llmsTxt: true,
|
llmsTxt: true,
|
||||||
mcp: { enabled: false },
|
mcp: { enabled: false },
|
||||||
},
|
},
|
||||||
// The only content source. `/changelog` is a custom page (pages/
|
// The only content source. `/changelog` and `/appendix` are custom pages
|
||||||
// changelog.astro) reading the GitHub releases itself — one timeline, no
|
// (pages/*.astro): `/changelog` reads the GitHub releases itself — one
|
||||||
// per-release pages, so nothing of it enters the sidebar or prev/next.
|
// timeline, no per-release pages — and `/appendix` is one glossary page
|
||||||
|
// built from appendix.ts, so neither enters the sidebar tree or prev/next.
|
||||||
content: {
|
content: {
|
||||||
sources: [filesystem({ root: "content" })],
|
sources: [filesystem({ root: "content" })],
|
||||||
},
|
},
|
||||||
@@ -139,7 +142,11 @@ export default defineConfig({
|
|||||||
sidebar: {
|
sidebar: {
|
||||||
display: "flat", // "flat" | "group" | "page"
|
display: "flat", // "flat" | "group" | "page"
|
||||||
},
|
},
|
||||||
// A plain header link on the right, not a tab.
|
// The glossary is no content folder any more, so it is pinned above the
|
||||||
actions: [{ href: "/changelog", label: "Changelog" }],
|
// sidebar tree, on every page and breakpoint.
|
||||||
|
featured: [
|
||||||
|
{ label: "Changelog", href: "/changelog", icon: "clock" },
|
||||||
|
{ label: "Appendix", href: "/appendix", icon: "library" },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user