Skip to content

Commit c17a168

Browse files
KianNHkodster28
authored andcommitted
[Docs Site] Add topic tags to right sidebar (cloudflare#22985)
* [Docs Site] Add topic tags to right sidebar * tracking * title and container * Update src/components/overrides/TableOfContents.astro --------- Co-authored-by: Kody Jackson <[email protected]>
1 parent 4f1bfb3 commit c17a168

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/components/overrides/TableOfContents.astro

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,32 @@ import Default from "@astrojs/starlight/components/TableOfContents.astro";
33
44
import { Icon } from "@astrojs/starlight/components";
55
import FeedbackPrompt from "../FeedbackPrompt.tsx";
6+
7+
const tags = Astro.locals.starlightRoute.entry.data.tags;
68
---
79

810
<Default />
11+
{
12+
tags && (
13+
<>
14+
<br />
15+
<div>
16+
<h2>Tags</h2>
17+
<div class="flex gap-2">
18+
{tags.map((tag) => (
19+
<a
20+
href={`/search/?tags=${tag}`}
21+
class="rounded-sm border border-(--sl-color-hairline) px-3 text-black"
22+
data-tag-serp-link={true}
23+
>
24+
{tag}
25+
</a>
26+
))}
27+
</div>
28+
</div>
29+
</>
30+
)
31+
}
932
<br />
1033
<FeedbackPrompt client:idle />
1134
{

src/scripts/analytics/links.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ export function registerLinks() {
1616
for (const el of elements) {
1717
const { hostname, pathname } = new URL(el.href);
1818

19+
if (el.dataset.tagSerpLink) {
20+
el.addEventListener("click", () => {
21+
track("click docs tag", { value: el.innerText });
22+
});
23+
24+
continue;
25+
}
26+
1927
if (hostname === "developers.cloudflare.com" || hostname === "localhost") {
2028
continue;
2129
}

0 commit comments

Comments
 (0)