Skip to content

Commit 5859e72

Browse files
committed
Use activePath to render breadcrumbs properly
1 parent ebe8634 commit 5859e72

File tree

3 files changed

+12
-21
lines changed

3 files changed

+12
-21
lines changed

src/_design-system/breadcrumbs.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Fragment } from "react"
22
import { clsx } from "clsx"
33
import NextLink from "next/link"
4-
import { ArrowRightIcon } from "nextra/icons"
54
import type { Item } from "nextra/normalize-pages"
65

76
import CaretDown from "@/app/conf/_design-system/pixelarticons/caret-down.svg?svgr"
@@ -37,7 +36,7 @@ export const Breadcrumbs = ({
3736
const className = clsx(
3837
"truncate text-neu-700 dark:text-neu-400 min-w-6 last:text-neu-800 dark:last:text-neu-800 leading-none",
3938
href &&
40-
"focus-visible:gql-focus-visible ring-inset hover:text-neu-900 hover:underline",
39+
"focus-visible:gql-focus-visible ring-inset hover:text-neu-900 hover:underline underline-offset-2",
4140
)
4241

4342
return (
@@ -46,7 +45,12 @@ export const Breadcrumbs = ({
4645
<CaretDown className="size-4 translate-x-[0.5px] -rotate-90" />
4746
)}
4847
{href ? (
49-
<NextLink href={href} title={title} prefetch={false}>
48+
<NextLink
49+
href={href}
50+
title={title}
51+
prefetch={false}
52+
className={className}
53+
>
5054
{item.title}
5155
</NextLink>
5256
) : (

src/components/tools-and-libraries.tsx

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ import Markdown from "markdown-to-jsx"
1616
import { evaluate } from "nextra/components"
1717
import { useCallback, useState, MouseEvent, useMemo, memo } from "react"
1818
import { clsx } from "clsx"
19-
import { Collapse, getComponents } from "nextra-theme-docs"
19+
import { Collapse, getComponents, useConfig } from "nextra-theme-docs"
2020
import { RadioGroup, Radio } from "@/components/radio"
2121
import { Button } from "@/app/conf/_design-system/button"
2222
import { Tag } from "@/app/conf/_design-system/tag"
2323
import SearchIcon from "@/app/conf/_design-system/pixelarticons/search.svg?svgr"
2424
import CaretDown from "@/app/conf/_design-system/pixelarticons/caret-down.svg?svgr"
2525
import { SidebarFooter } from "./sidebar"
26+
import { Breadcrumbs } from "../_design-system/breadcrumbs"
2627

2728
type PackageInfo = {
2829
name: string
@@ -60,6 +61,7 @@ export function CodePage({ allTags, data }: CodePageProps) {
6061
[],
6162
)
6263

64+
const { activePath } = useConfig().normalizePagesResult
6365
const [searchParams, setSearchParams] = useSearchParamsState()
6466
const [search, setSearch] = useState("")
6567
const normalizedSearch = useMemo(() => search.trim().toLowerCase(), [search])
@@ -88,21 +90,6 @@ export function CodePage({ allTags, data }: CodePageProps) {
8890
[setSearchParams],
8991
)
9092

91-
const handleQuery = useCallback(
92-
(e: MouseEvent<HTMLAnchorElement | HTMLButtonElement>) => {
93-
e.preventDefault()
94-
const tag = e.currentTarget.dataset.tag!
95-
96-
updateTags(prevTags => {
97-
if (prevTags.includes(tag)) {
98-
return prevTags.filter(t => t !== tag)
99-
}
100-
return [...prevTags, tag]
101-
})
102-
},
103-
[updateTags],
104-
)
105-
10693
const mounted = useMounted()
10794

10895
const { newData, tagCounts } = useMemo(() => {
@@ -312,7 +299,6 @@ export function CodePage({ allTags, data }: CodePageProps) {
312299
}, [selectedTags, allTagsMap])
313300

314301
const [sort, setSort] = useState("popularity")
315-
const [isCollapsing, setIsCollapsing] = useState(false)
316302

317303
let description = `A collection of tools and libraries for GraphQL`
318304
let title = "Tools and Libraries | GraphQL"
@@ -336,6 +322,7 @@ export function CodePage({ allTags, data }: CodePageProps) {
336322
/>
337323
</NextHead>
338324
<div className="gql-container gql-section pb-8">
325+
<Breadcrumbs className="" activePath={activePath} />
339326
<div className="relative mt-8 flex md:gap-8">
340327
<aside>
341328
<Collapse horizontal isOpen={showSidebar}>

src/pages/community/_meta.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
export default {
2+
resources: "Resources",
23
"tools-and-libraries": {
34
theme: {
45
layout: "raw",
56
},
67
},
7-
resources: "Resources",
88
events: "",
99
contribute: "Contribute to GraphQL",
1010
foundation: "Foundation",

0 commit comments

Comments
 (0)