File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ import { getCollection } from " astro:content" ;
3+ import { ALPHABETS } from " ../../../../constants.js" ;
4+ import BaseLayout from " ../../../layouts/base.astro" ;
5+
6+ const { page } = Astro .props ;
7+ const params = Astro .params ;
8+
9+ export const prerender = true ;
10+
11+ export async function getStaticPaths({ paginate }) {
12+ const dictionary = await getCollection (" dictionary" );
13+ return ALPHABETS .flatMap (alpha => {
14+ const filteredWords = dictionary .filter (word => word .slug [0 ] === alpha );
15+ console .log (filteredWords );
16+
17+ return paginate (filteredWords , {
18+ params: { alpha },
19+ pageSize: 1
20+ });
21+ });
22+ }
23+ ---
24+
25+ <BaseLayout >
26+ <main class =" max-w-screen-lg p-5 md:mt-10 mx-auto min-h-screen space-y-6" >
27+ <h1 class =" text-3xl md:text-5xl font-black" >
28+ Browse: Letter { params .alpha .toUpperCase () }
29+ </h1 >
30+ <div >
31+ { page .data .map (word => (
32+ <a href = { ` /browse/${word .slug } ` }
33+ class = " flex items-center md:text-lg justify-between no-underline w-full p-4 even:bg-gray-100 hover:bg-gray-100/50"
34+ >
35+ <span >{ word .data .title } </span >
36+ <svg xmlns = " http://www.w3.org/2000/svg" fill = " none" viewBox = " 0 0 24 24" stroke-width = " 1.5" stroke = " currentColor" class = " w-4 h-4" >
37+ <path stroke-linecap = " round" stroke-linejoin = " round" d = " m8.25 4.5 7.5 7.5-7.5 7.5" ></path >
38+ </svg >
39+ </a >
40+ ))}
41+ </div >
42+ </main >
43+ </BaseLayout >
You can’t perform that action at this time.
0 commit comments