From 048ccc6ac833350af4773c1b209f5aed3274a9c2 Mon Sep 17 00:00:00 2001 From: Filipe Medeiros Date: Tue, 12 Mar 2024 18:35:38 +0000 Subject: [PATCH] update metadata component --- .../src/components/BlogPostMetadata.astro | 26 --------------- frontend/src/components/Metadata.astro | 33 +++++++++++++++++++ frontend/src/layouts/Layout.astro | 4 +-- frontend/src/pages/biblioteca/index.astro | 12 +++---- frontend/src/pages/blog/[slug]/index.astro | 13 +++----- frontend/src/pages/blog/index.astro | 7 +++- frontend/src/pages/blogue/[slug]/index.astro | 13 +++----- frontend/src/pages/blogue/index.astro | 9 ++--- frontend/src/pages/home.astro | 8 ++++- frontend/src/pages/index.astro | 14 ++++---- frontend/src/pages/library/index.astro | 12 +++---- 11 files changed, 78 insertions(+), 73 deletions(-) delete mode 100644 frontend/src/components/BlogPostMetadata.astro create mode 100644 frontend/src/components/Metadata.astro diff --git a/frontend/src/components/BlogPostMetadata.astro b/frontend/src/components/BlogPostMetadata.astro deleted file mode 100644 index 99f509b..0000000 --- a/frontend/src/components/BlogPostMetadata.astro +++ /dev/null @@ -1,26 +0,0 @@ ---- -import type { CollectionEntry } from 'astro:content'; -import { getImage } from 'astro:assets'; -import allLinkPreviewImages from '../lib/allLinkPreviewImages'; - -export type Props = CollectionEntry<'blog'>['data']['linkPreview']; - -const { description, image, title } = Astro.props; - -const imageUrl = ( - await getImage({ - src: allLinkPreviewImages[image.path](), - width: 1200, - height: 630, - }) -).src; ---- - - - - - - - - - diff --git a/frontend/src/components/Metadata.astro b/frontend/src/components/Metadata.astro new file mode 100644 index 0000000..0520602 --- /dev/null +++ b/frontend/src/components/Metadata.astro @@ -0,0 +1,33 @@ +--- +import { getImage } from 'astro:assets'; +import allLinkPreviewImages from '../lib/allLinkPreviewImages'; + +export interface Props { + title: string; + description: string; + image?: { + path: string; + altText: string; + }; +} + +const { description, image, title } = Astro.props; + +const imageUrl = image + ? ( + await getImage({ + src: allLinkPreviewImages[image.path](), + width: 1200, + height: 630, + }) + ).src + : null; +--- + +{title} + + + +{imageUrl && } +{image && } + diff --git a/frontend/src/layouts/Layout.astro b/frontend/src/layouts/Layout.astro index 13c49f8..2725501 100644 --- a/frontend/src/layouts/Layout.astro +++ b/frontend/src/layouts/Layout.astro @@ -2,13 +2,12 @@ import InlineLink from '../components/InlineLink.astro'; export interface Props { - title: string; ptUrl: string; enUrl: string; lang: string; } -const { title, ptUrl, enUrl, lang } = Astro.props; +const { ptUrl, enUrl, lang } = Astro.props; const { footer } = Astro.slots; const hasFooter = !!footer; --- @@ -18,7 +17,6 @@ const hasFooter = !!footer; - {title} diff --git a/frontend/src/pages/biblioteca/index.astro b/frontend/src/pages/biblioteca/index.astro index ff8c06e..e3846de 100644 --- a/frontend/src/pages/biblioteca/index.astro +++ b/frontend/src/pages/biblioteca/index.astro @@ -1,6 +1,7 @@ --- import ButtonLink from '../../components/ButtonLink.astro'; import CardLink from '../../components/CardLink.astro'; +import Metadata from '../../components/Metadata.astro'; import PageTitle from '../../components/PageTitle.astro'; import Layout from '../../layouts/Layout.astro'; import { getCollection } from 'astro:content'; @@ -10,12 +11,11 @@ const libraryItems = ( ).sort((a, b) => b.data.date.getTime() - a.data.date.getTime()); --- - + +
Biblioteca

diff --git a/frontend/src/pages/blog/[slug]/index.astro b/frontend/src/pages/blog/[slug]/index.astro index 62e85cc..794e027 100644 --- a/frontend/src/pages/blog/[slug]/index.astro +++ b/frontend/src/pages/blog/[slug]/index.astro @@ -3,7 +3,7 @@ import BlogPostSubtitle from '../../../components/BlogPostSubtitle.astro'; import ButtonLink from '../../../components/ButtonLink.astro'; import PageTitle from '../../../components/PageTitle.astro'; import Layout from '../../../layouts/Layout.astro'; -import BlogPostMetadata from '../../../components/BlogPostMetadata.astro'; +import Metadata from '../../../components/Metadata.astro'; import { getCollection } from 'astro:content'; import type { CollectionEntry } from 'astro:content'; import blogPostComponents from '../../../components/mdx/blogPostComponents'; @@ -53,15 +53,10 @@ const formattedPublishDate = publishDate.toLocaleDateString('pt', { }); --- - - + diff --git a/frontend/src/pages/blog/index.astro b/frontend/src/pages/blog/index.astro index 9657d57..67436d9 100644 --- a/frontend/src/pages/blog/index.astro +++ b/frontend/src/pages/blog/index.astro @@ -4,13 +4,18 @@ import ButtonLink from '../../components/ButtonLink.astro'; import CardLink from '../../components/CardLink.astro'; import PageTitle from '../../components/PageTitle.astro'; import Layout from '../../layouts/Layout.astro'; +import Metadata from '../../components/Metadata.astro'; const posts = ( await getCollection('blog', ({ id }) => id.startsWith('en')) ).sort((a, b) => b.data.publishDate.getTime() - a.data.publishDate.getTime()); --- - + +

Blog

Uma coleção de artigos que vou escrevendo. Sobretudo por diversão.

diff --git a/frontend/src/pages/blogue/[slug]/index.astro b/frontend/src/pages/blogue/[slug]/index.astro index 11f80f7..2eeacb5 100644 --- a/frontend/src/pages/blogue/[slug]/index.astro +++ b/frontend/src/pages/blogue/[slug]/index.astro @@ -3,7 +3,7 @@ import BlogPostSubtitle from '../../../components/BlogPostSubtitle.astro'; import ButtonLink from '../../../components/ButtonLink.astro'; import PageTitle from '../../../components/PageTitle.astro'; import Layout from '../../../layouts/Layout.astro'; -import BlogPostMetadata from '../../../components/BlogPostMetadata.astro'; +import Metadata from '../../../components/Metadata.astro'; import { getCollection } from 'astro:content'; import type { CollectionEntry } from 'astro:content'; import blogPostComponents from '../../../components/mdx/blogPostComponents'; @@ -53,15 +53,10 @@ const formattedPublishDate = publishDate.toLocaleDateString('pt', { }); --- - - + diff --git a/frontend/src/pages/blogue/index.astro b/frontend/src/pages/blogue/index.astro index 15fa3a5..e32f801 100644 --- a/frontend/src/pages/blogue/index.astro +++ b/frontend/src/pages/blogue/index.astro @@ -1,6 +1,7 @@ --- import ButtonLink from '../../components/ButtonLink.astro'; import CardLink from '../../components/CardLink.astro'; +import Metadata from '../../components/Metadata.astro'; import PageTitle from '../../components/PageTitle.astro'; import Layout from '../../layouts/Layout.astro'; @@ -11,12 +12,8 @@ const posts = ( ).sort((a, b) => b.data.publishDate.getTime() - a.data.publishDate.getTime()); --- - + +
Blogue

Uma coleção de artigos que vou escrevendo. Sobretudo por diversão.

diff --git a/frontend/src/pages/home.astro b/frontend/src/pages/home.astro index 4d81131..08c22ce 100644 --- a/frontend/src/pages/home.astro +++ b/frontend/src/pages/home.astro @@ -1,11 +1,17 @@ --- import ButtonLink from '../components/ButtonLink.astro'; import InlineLink from '../components/InlineLink.astro'; +import Metadata from '../components/Metadata.astro'; import PageTitle from '../components/PageTitle.astro'; import Layout from '../layouts/Layout.astro'; --- - + + Filipe
Medeiros
diff --git a/frontend/src/pages/index.astro b/frontend/src/pages/index.astro index 5c70f0d..a0121e2 100644 --- a/frontend/src/pages/index.astro +++ b/frontend/src/pages/index.astro @@ -3,14 +3,16 @@ import ButtonLink from '../components/ButtonLink.astro'; import InlineLink from '../components/InlineLink.astro'; import PageTitle from '../components/PageTitle.astro'; import Layout from '../layouts/Layout.astro'; +import Metadata from '../components/Metadata.astro'; --- - + + + Filipe
Medeiros
diff --git a/frontend/src/pages/library/index.astro b/frontend/src/pages/library/index.astro index 59340c4..c205c4f 100644 --- a/frontend/src/pages/library/index.astro +++ b/frontend/src/pages/library/index.astro @@ -1,6 +1,7 @@ --- import ButtonLink from '../../components/ButtonLink.astro'; import CardLink from '../../components/CardLink.astro'; +import Metadata from '../../components/Metadata.astro'; import PageTitle from '../../components/PageTitle.astro'; import Layout from '../../layouts/Layout.astro'; import { getCollection } from 'astro:content'; @@ -10,12 +11,11 @@ const libraryItems = ( ).sort((a, b) => b.data.date.getTime() - a.data.date.getTime()); --- - + +
Library