mirror of
https://github.com/prdlk/leetcode.git
synced 2026-11-02 13:12:44 +00:00
docs(changelog): link problems using short redirects instead of issue URLs
This commit is contained in:
1 parent
4b8496c113
commit
fd57f53d34
2 files changed
+20
-14
No files matched your search
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
import PageLayout from "blume/components/layout/PageLayout.astro";
|
||||
import data from "blume:data";
|
||||
import { withBase } from "blume/components/islands/base-path.ts";
|
||||
import redirects from "../redirects";
|
||||
import { readReleases } from "../lib/releases.ts";
|
||||
|
||||
const { config } = data;
|
||||
@@ -19,6 +21,14 @@ const DATE = new Intl.DateTimeFormat("en-US", {
|
||||
year: "numeric",
|
||||
});
|
||||
const issueUrl = (n: number) => `https://github.com/prdlk/leetcode/issues/${n}`;
|
||||
// LC number -> its docs page route, off sync's `/<num>` short links — the
|
||||
// page itself, not the redirect, so a click is one hop. A problem with no page
|
||||
// (none yet) links to its issue instead.
|
||||
const pages = new Map(redirects.map((r) => [Number(r.from.slice(1)), r.to]));
|
||||
const problemHref = (lc: number, issue: number) => {
|
||||
const route = pages.get(lc);
|
||||
return route ? withBase(route) : issueUrl(issue);
|
||||
};
|
||||
// The /progress cards' difficulty palette (--chart-1..3 in theme.css), so a
|
||||
// Hard reads the same colour here as in the SolvedRing gauge.
|
||||
const DIFFICULTY: Record<string, { label: string; class: string }> = {
|
||||
@@ -84,8 +94,7 @@ const description = "Every topic and review the campaign finished, newest first.
|
||||
<span class="select-none text-border" aria-hidden="true">—</span>
|
||||
<span class="min-w-0">
|
||||
<span class="mr-2 font-mono text-xs uppercase tracking-wide">{p.set}</span>
|
||||
{/* The problem's docs page; its issue only until it has one. */}
|
||||
<a class="text-foreground no-underline hover:underline" href={p.docs ?? issueUrl(p.issue)}>
|
||||
<a class="text-foreground no-underline hover:underline" href={problemHref(p.lc, p.issue)}>
|
||||
{p.title}
|
||||
</a>
|
||||
{DIFFICULTY[p.difficulty] && (
|
||||
|
||||
Reference in new issue
Block a user