Skip to content

Commit

Permalink
improvement: change language/translator/work landing page design
Browse files Browse the repository at this point in the history
make language/translator/work page list all values as links to the search page with appropriate
facetting activated (refs #3)
  • Loading branch information
kevinstadler committed Sep 23, 2024
1 parent 3c1f35f commit 2d8e117
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/languages/[language]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function LanguagesPage(props: LanguagesPageProps) {
<SimpleListing
facetingField="language"
facetingValue={props.params?.language}
path="languages"
path="language"
/>
);
}
2 changes: 1 addition & 1 deletion app/translators/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function TranslatorsPage(props: TranslatorsPageProps) {
facetingField="contains.translators.name"
// FIXME ugly
facetingValue={props.params ? decodeURI(props.params.id) : undefined}
path="translators"
path="translator"
/>
);
}
3 changes: 1 addition & 2 deletions app/works/[category]/[work]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ export default function WorksPage(props: WorksPageProps) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
`contains.work.category := ${catt(props.params?.category as any)}`
}
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
path={`works/${props.params?.category}`}
path={`work`}
/>
</div>
);
Expand Down
24 changes: 10 additions & 14 deletions components/simple-listing.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { getFaceted } from "@/lib/data";

import { AppNavLink } from "./app-nav-link";
import { InstantSearch } from "./instantsearch";
import { MainContent } from "./main-content";

export interface SimpleListingProps {
Expand All @@ -15,19 +14,16 @@ export async function SimpleListing(props: SimpleListingProps) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const counts = (await getFaceted(props.facetingField, props.filter_by)).facet_counts?.[0]!.counts;
return (
<MainContent>
<div>
{counts?.map((c) => {
return (
<li key={c.value}>
<AppNavLink href={`/${props.path}/${c.value}`}>
{c.value}&nbsp;({c.count})
</AppNavLink>
</li>
);
})}
</div>
<div>{props.facetingValue ? <InstantSearch faceting={props} /> : null}</div>
<MainContent className="grid grid-cols-[repeat(auto-fit,minmax(15rem,1fr))]">
{counts?.map((c) => {
return (
<div key={c.value}>
<AppNavLink href={`/search?${props.path}=${c.value}`}>
{c.value}&nbsp;({c.count})
</AppNavLink>
</div>
);
})}
</MainContent>
);
}

0 comments on commit 2d8e117

Please sign in to comment.