mirror of
https://github.com/prdlk/leetcode.git
synced 2026-11-02 13:12:44 +00:00
feat(components): add GitHub issue badge to problem badges
This commit is contained in:
1 parent
c05e7f0ef2
commit
a20be5182f
1 file changed
+15
-4
@@ -12,7 +12,7 @@
|
|||||||
* - `topics:` (problem pages, written by `apps/cli/sync.ts`) is LeetCode's own
|
* - `topics:` (problem pages, written by `apps/cli/sync.ts`) is LeetCode's own
|
||||||
* topic tags. A tag the campaign teaches (`topic-landings.ts`) links to that
|
* topic tags. A tag the campaign teaches (`topic-landings.ts`) links to that
|
||||||
* topic's landing page and is filled; any other tag links to its guide
|
* topic's landing page and is filled; any other tag links to its guide
|
||||||
* page, `/guides/<slug>` (sync creates one per such tag), and is outlined.
|
* page in the Appendix, `/appendix/<slug>` (sync creates one per such tag), and is outlined.
|
||||||
* `tagTarget()` picks the route (and between two landings, e.g. DFS); the
|
* `tagTarget()` picks the route (and between two landings, e.g. DFS); the
|
||||||
* `PageFooter` backlinks list reads the same answer. Each tag badge is a
|
* `PageFooter` backlinks list reads the same answer. Each tag badge is a
|
||||||
* pill carrying the icon its target shows in the sidebar (the topic's
|
* pill carrying the icon its target shows in the sidebar (the topic's
|
||||||
@@ -22,7 +22,10 @@
|
|||||||
* furthest apart. A tag with no page (the LeetCode-list fallback) stays
|
* furthest apart. A tag with no page (the LeetCode-list fallback) stays
|
||||||
* gray and iconless.
|
* gray and iconless.
|
||||||
* - `video:` (problem pages, written by `apps/cli/videos.ts`) is the NeetCode
|
* - `video:` (problem pages, written by `apps/cli/videos.ts`) is the NeetCode
|
||||||
* walkthrough's YouTube id, the red "Explanation" badge at the end of the row.
|
* walkthrough's YouTube id, the red "Explanation" badge.
|
||||||
|
* - `issue:` (problem pages, written by sync) is the problem's GitHub issue
|
||||||
|
* URL, a neutral "Issue #N" badge with the GitHub mark, right after
|
||||||
|
* "Explanation" at the end of the row.
|
||||||
* - `list:` (guide pages, written by sync on create) is the tag's LeetCode
|
* - `list:` (guide pages, written by sync on create) is the tag's LeetCode
|
||||||
* problem list, an orange "LeetCode list" badge.
|
* problem list, an orange "LeetCode list" badge.
|
||||||
*/
|
*/
|
||||||
@@ -44,6 +47,7 @@ const entry = at ? await getEntry(at.collection, at.entryId) : undefined;
|
|||||||
const tags: TopicTag[] = entry?.data.topics ?? [];
|
const tags: TopicTag[] = entry?.data.topics ?? [];
|
||||||
const video: string | undefined = entry?.data.video;
|
const video: string | undefined = entry?.data.video;
|
||||||
const list: string | undefined = entry?.data.list;
|
const list: string | undefined = entry?.data.list;
|
||||||
|
const issue: string | undefined = entry?.data.issue;
|
||||||
|
|
||||||
const served = new Set<string>(data.routes.map((r: { path: string }) => r.path));
|
const served = new Set<string>(data.routes.map((r: { path: string }) => r.path));
|
||||||
|
|
||||||
@@ -70,7 +74,7 @@ const colors = tags.length
|
|||||||
? tagColors(
|
? tagColors(
|
||||||
[
|
[
|
||||||
...Object.keys(TOPIC_LANDINGS),
|
...Object.keys(TOPIC_LANDINGS),
|
||||||
...[...served].flatMap((path) => path.match(/^\/guides\/([^/]+)$/u)?.slice(1) ?? []),
|
...[...served].flatMap((path) => path.match(/^\/appendix\/([^/]+)$/u)?.slice(1) ?? []),
|
||||||
],
|
],
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
data.routes
|
data.routes
|
||||||
@@ -100,7 +104,7 @@ const linkClass = "no-underline transition-opacity hover:opacity-80";
|
|||||||
---
|
---
|
||||||
|
|
||||||
{
|
{
|
||||||
(badges.length > 0 || video || list) && (
|
(badges.length > 0 || video || list || issue) && (
|
||||||
<div class="not-prose mb-6 flex flex-wrap gap-1.5">
|
<div class="not-prose mb-6 flex flex-wrap gap-1.5">
|
||||||
{badges.map((b) => (
|
{badges.map((b) => (
|
||||||
<a
|
<a
|
||||||
@@ -121,6 +125,13 @@ const linkClass = "no-underline transition-opacity hover:opacity-80";
|
|||||||
</Badge>
|
</Badge>
|
||||||
</a>
|
</a>
|
||||||
)}
|
)}
|
||||||
|
{issue && (
|
||||||
|
<a href={issue} target="_blank" rel="noopener" class={linkClass}>
|
||||||
|
<Badge icon="github" shape="pill">
|
||||||
|
Issue #{issue.slice(issue.lastIndexOf("/") + 1)}
|
||||||
|
</Badge>
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
{list && (
|
{list && (
|
||||||
<a href={list} target="_blank" rel="noopener" class={linkClass}>
|
<a href={list} target="_blank" rel="noopener" class={linkClass}>
|
||||||
<Badge variant="warning" icon="list" shape="pill">
|
<Badge variant="warning" icon="list" shape="pill">
|
||||||
|
|||||||
Reference in new issue
Block a user