diff --git a/src/assets/style/global.css b/src/assets/style/global.css index 368214c..8c6c40b 100644 --- a/src/assets/style/global.css +++ b/src/assets/style/global.css @@ -57,6 +57,16 @@ ul { margin: 0; } +.list-unstyle { + list-style: none; +} + +img, +video { + max-width: 100%; + height: auto; +} + li:not(:last-child) { margin-bottom: var(--prj-spacing-1); } diff --git a/src/components/Card.astro b/src/components/Card.astro index cb5591b..b73b569 100644 --- a/src/components/Card.astro +++ b/src/components/Card.astro @@ -1,11 +1,7 @@ --- export interface Props { - title: string; - body: string; - href: string; + title?: string; } - -const { href, title, body } = Astro.props; ---
diff --git a/src/components/MediaGallery/Gallery.tsx b/src/components/MediaGallery/Gallery.tsx new file mode 100644 index 0000000..bfdb83f --- /dev/null +++ b/src/components/MediaGallery/Gallery.tsx @@ -0,0 +1,44 @@ +import React from 'react'; +import { MediaType, type Media } from './types'; + +interface Props { + items: Media[]; +} + +// TODO: transform this component in a lightbox +export default function Gallery({ items }: Props): JSX.Element { + const renderItem = (item: Media): JSX.Element => { + // get the file id from the "share" link of google drive + const googleFileId = item.url.split('/').at(5); + let url; + switch (item.type) { + case MediaType.Image: + url = + googleFileId !== undefined + ? `https://drive.google.com/uc?export=preview&id=${googleFileId}` + : item.url; + return {item.alt}; + case MediaType.Video: + url = + googleFileId !== undefined + ? `https://drive.google.com/file/d/${googleFileId}/preview` + : item.url; + return ( + + ); + + default: + break; + } + + return <>; + }; + + return ( + + ); +} diff --git a/src/components/MediaGallery/types.ts b/src/components/MediaGallery/types.ts new file mode 100644 index 0000000..bd50daf --- /dev/null +++ b/src/components/MediaGallery/types.ts @@ -0,0 +1,11 @@ +export enum MediaType { + Image = 'image', + Video = 'video', +} + +export interface Media { + type: MediaType; + url: string; + alt: string; + mime?: string; +} diff --git a/src/content b/src/content index 6b40694..e52081e 160000 --- a/src/content +++ b/src/content @@ -1 +1 @@ -Subproject commit 6b406948b70fa4c56333c0afc628e9b6618aacdc +Subproject commit e52081e1e2d2acaf810e9902a009aaa372313ae6 diff --git a/src/pages/index.astro b/src/pages/index.astro index 0d0d92b..4c71c47 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -5,7 +5,15 @@ import Card from '../components/Card.astro'; import { Image } from 'astro:assets'; import portrait from '../assets/images/portrait.jpg'; -const games = await getCollection('games', (_, idx) => idx < 3); +const games = await getCollection('games'); + +const blog = await getCollection('blog', ({ data }) => + import.meta.env.PROD ? data.draft !== true : true, +); +// TODO: show the pinned ones, not the recents +const portafolio = await getCollection('portafolio', ({ data }) => + import.meta.env.PROD ? data.draft !== true : true, +); --- @@ -34,29 +42,29 @@ const games = await getCollection('games', (_, idx) => idx < 3);

Portafolio

Blog

See more... @@ -67,7 +75,7 @@ const games = await getCollection('games', (_, idx) => idx < 3);

Games

    { - games.map((item) => ( + games.slice(0, 3).map((item) => (
  • {item.data.title}
  • diff --git a/src/pages/portafolio/[...slug].astro b/src/pages/portafolio/[...slug].astro new file mode 100644 index 0000000..f4b9b4f --- /dev/null +++ b/src/pages/portafolio/[...slug].astro @@ -0,0 +1,31 @@ +--- +import type { InferGetStaticPropsType, GetStaticPaths } from 'astro'; +import { getCollection } from 'astro:content'; +import Layout from '@layouts/Layout.astro'; +import Toc from '@components/Toc/Toc'; +import Gallery from '@components/MediaGallery/Gallery'; + +export const getStaticPaths = (async () => { + const entries = await getCollection('portafolio'); + + return entries.map((entry) => ({ + params: { slug: entry.slug }, + props: entry, + })); +}) satisfies GetStaticPaths; + +type Props = InferGetStaticPropsType; + +const entry = Astro.props; +const { Content, headings } = await entry.render(); +--- + + +

    {entry.data.title}

    + + + + + + +
    diff --git a/src/pages/portafolio/index.astro b/src/pages/portafolio/index.astro new file mode 100644 index 0000000..bbf2fa7 --- /dev/null +++ b/src/pages/portafolio/index.astro @@ -0,0 +1,43 @@ +--- +import { getCollection } from 'astro:content'; +import Layout from '@layouts/Layout.astro'; +import Table from '@components/Table'; +import { HeaderType, type Header } from '@components/Table/types'; + +const rawEntries = await getCollection('portafolio', ({ data }) => { + return import.meta.env.PROD ? data.draft !== true : true; +}); + +const entries = rawEntries.map((item, idx) => ({ + ...item.data, + id: idx + 1, + slug: item.slug, +})); + +const headers: Header[] = [ + { + key: 'id', + header: 'index', + type: HeaderType.Index, + }, + { + key: 'title', + header: 'Title', + formatter: (data) => `${data.title}`, + type: HeaderType.String, + }, + { + key: 'technologies', + header: 'Technologies', + type: HeaderType.Multiple, + }, +]; +--- + + +

    Blog's entries

    + +
    + + +