Skip to content

Commit 3e97704

Browse files
committed
improve people search result links
1 parent c15aa01 commit 3e97704

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

src/layouts/PeopleLayout.astro

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { CollectionEntry } from "astro:content";
66
import { setJumpToState } from "../globals/state";
77
import { getCurrentLocale, getUiTranslator } from "../i18n/utils";
88
import lodash from "lodash";
9+
import { removeLocaleAndExtension } from "../pages/_utils";
910
1011
interface Props {
1112
entries: CollectionEntry<"people">[];
@@ -66,7 +67,10 @@ setJumpToState(null);
6667
<h2>{category.label}</h2>
6768
<ul class="content-grid">
6869
{category.members.map((person) => (
69-
<li class="col-span-6 md:col-span-9 lg:col-span-12 content-grid">
70+
<li
71+
id={removeLocaleAndExtension(person.id)}
72+
class="col-span-6 md:col-span-9 lg:col-span-12 content-grid"
73+
>
7074
<div class="col-span-4 md:col-span-9 lg:col-span-4">
7175
<Image
7276
src={person.data.image!}
@@ -101,7 +105,7 @@ setJumpToState(null);
101105
<ul class="content-grid-simple !gap-y-0">
102106
{
103107
lodash.shuffle(contributorEntries.members).map((person) => (
104-
<li class="col-span-1">
108+
<li class="col-span-1" id={removeLocaleAndExtension(person.id)}>
105109
<a
106110
href={person.data.url}
107111
aria-label={`Link to ${person.data.name}'s personal website'`}

src/scripts/builders/search.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import keywordExtractor from "keyword-extractor";
1010
import { contentTypes } from "../../globals/globals";
1111
import { supportedLocales as localesWithSearchSupport } from "../../i18n/const";
1212
import type { LanguageName } from "keyword-extractor/types/lib/keyword_extractor";
13+
import { removeLocalePrefix } from "@/src/i18n/utils";
1314

1415
interface SearchIndex {
1516
[title: string]: {
@@ -248,7 +249,12 @@ const generateSearchIndex = async (
248249
break;
249250
case "people":
250251
title = data.name;
251-
relativeUrl = `/people/`;
252+
relativeUrl = `/people/#${data.name
253+
// copied from people build script
254+
.toLowerCase()
255+
.normalize("NFD")
256+
.replaceAll(/[\u0300-\u036f]/g, "")
257+
.replaceAll(/[ ._<>*%\\/]/g, "-")}`;
252258
break;
253259
case "events":
254260
title = data.title;

0 commit comments

Comments
 (0)