diff --git a/src/components/Table/Filters/index.tsx b/src/components/Table/Filters/index.tsx index 5c9c2e1..213ca6a 100644 --- a/src/components/Table/Filters/index.tsx +++ b/src/components/Table/Filters/index.tsx @@ -3,8 +3,8 @@ import { HeaderType, type Filter, type Value } from '../types.ts'; export { default as SelectFilter } from './SelectFilter.tsx'; export { default as NumberFilter } from './NumberFilter.tsx'; -const filterString = (value: Value, data: any): boolean => { - return data.search(value) !== -1; +const filterString = (value: string, data: string): boolean => { + return data.toLowerCase().search(value.toLowerCase()) !== -1; }; const filterNumber = (value: Value, data: any): boolean => { if (!Array.isArray(value)) { diff --git a/src/components/Table/Table.tsx b/src/components/Table/Table.tsx index a4b75a5..4fb4f66 100644 --- a/src/components/Table/Table.tsx +++ b/src/components/Table/Table.tsx @@ -48,10 +48,8 @@ export default function Table({ data, headers }: Props): JSX.Element { // and because Astro don't allow me to pass JSX from an Astro file to a TSX file, // so I have to pass the formatted row as a string. // DON'T use this method on a public API - if (header.formatter != null) { - return ( -
- ); + if (header.hasCustomCell) { + return
; } if (header.type === HeaderType.Multiple) { diff --git a/src/components/Table/types.ts b/src/components/Table/types.ts index 995293c..e579009 100644 --- a/src/components/Table/types.ts +++ b/src/components/Table/types.ts @@ -13,7 +13,7 @@ export enum HeaderType { export interface Header { key: string; header: string; - formatter?: (data: DataItem) => string; + hasCustomCell: boolean; type: HeaderType; } diff --git a/src/content b/src/content index e740dda..2fed5c0 160000 --- a/src/content +++ b/src/content @@ -1 +1 @@ -Subproject commit e740dda6515e13c9632e1c560664d88492ebfe2f +Subproject commit 2fed5c0abfa4f778dc5acc6c4e7c527671ace48b diff --git a/src/pages/games/[...slug].astro b/src/pages/games/[...slug].astro index 8480d5b..f6116a6 100644 --- a/src/pages/games/[...slug].astro +++ b/src/pages/games/[...slug].astro @@ -5,6 +5,8 @@ import { GetStaticPaths, } from 'astro'; import { getCollection } from 'astro:content'; +import Layout from '@layouts/Layout.astro'; +import Toc from '@components/Toc/Toc'; export const getStaticPaths = (async () => { const games = await getCollection('games'); @@ -21,26 +23,8 @@ const entry = Astro.props; const { Content, headings } = await entry.render(); --- - - - - - - - - - + + - - - + + diff --git a/src/pages/games/index.astro b/src/pages/games/index.astro index 47a27ad..a9e3b80 100644 --- a/src/pages/games/index.astro +++ b/src/pages/games/index.astro @@ -6,12 +6,17 @@ import { HeaderType, type Header } from '@components/Table/types'; const rawGames = await getCollection('games'); -const games = rawGames.map((item, idx) => ({ +let games = rawGames.map((item, idx) => ({ ...item.data, id: idx + 1, slug: item.slug, + customCell: item.data.has_content + ? `${item.data.title}` + : `
${item.data.title}
`, })); +games = games.sort((a, b) => b.date_added.getTime() - a.date_added.getTime()); + const headers: Header[] = [ { key: 'id', @@ -21,9 +26,8 @@ const headers: Header[] = [ { key: 'title', header: 'Title', - // TODO: uncomment this when we are ready ton show a single page game. - // formatter: (data) => `${data.title}`, type: HeaderType.String, + hasCustomCell: true, }, { key: 'status', diff --git a/src/pages/index.astro b/src/pages/index.astro index eb48da7..89f6a37 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -5,7 +5,10 @@ import Card from '../components/Card.astro'; import { Image } from 'astro:assets'; import portrait from '../assets/images/portrait.jpg'; -const games = await getCollection('games'); +let games = await getCollection('games', ({ data }) => data.has_content); +games = games.sort( + (a, b) => b.data.date_added.getTime() - a.data.date_added.getTime(), +); const blog = await getCollection('blog', ({ data }) => import.meta.env.PROD ? data.draft !== true : true, @@ -37,8 +40,12 @@ const portafolio = await getCollection('portafolio', ({ data }) =>

- The first version of this project was developed as a MVP. So this sites lacks many features I would like to add over time. - For an up to date roadmap, please visit the project README. + The first version of this project was developed as a MVP. So this sites lacks many features I would like to add over time. For an + up to date roadmap, please visit the project README.