From 43950ae134ac16d1a3f2eb6418e7cf6a87b6d500 Mon Sep 17 00:00:00 2001 From: sergeyyarkov Date: Sat, 18 Feb 2023 23:39:27 +0300 Subject: [PATCH] refactor --- src/components/ArticleContent.astro | 3 ++ src/components/ArticleItem.astro | 20 ++++--------- src/components/PageHeading.astro | 3 +- src/content/config.ts | 2 +- src/i18n/utils.ts | 4 +-- src/pages/[...blog].astro | 46 +++++++++++++++++++++-------- src/pages/rss.xml.ts | 11 ++++--- src/utils/article.ts | 14 +++++++++ 8 files changed, 67 insertions(+), 36 deletions(-) diff --git a/src/components/ArticleContent.astro b/src/components/ArticleContent.astro index 6ef94bc..ba29de4 100644 --- a/src/components/ArticleContent.astro +++ b/src/components/ArticleContent.astro @@ -206,6 +206,9 @@ & .languages-available { margin: 25px 0; font-size: var(--font-size-lg); + & a:not(:last-child)::after { + content: ","; + } } } diff --git a/src/components/ArticleItem.astro b/src/components/ArticleItem.astro index fd949ca..fdb7ffb 100644 --- a/src/components/ArticleItem.astro +++ b/src/components/ArticleItem.astro @@ -1,23 +1,19 @@ --- import type { CollectionEntry } from "astro:content"; -import slugify from "@sindresorhus/slugify"; import { URL_BLOG_PREFIX } from "@root/pages/[...blog].astro"; -import { DEFAULT_LANGUAGE } from "@root/constants"; import { getLanguageFromURL } from "@i18n/utils"; -import { createDateFormatter } from "@root/utils"; +import { createDateFormatter, createRelativeArticleUrl } from "@root/utils"; export interface Props { entry: CollectionEntry<"blog">; } const pageLang = getLanguageFromURL(Astro.url.pathname); +const { entry } = Astro.props as Props; const { - entry: { - id, - data: { title, pubDate }, - }, -} = Astro.props as Props; -const slug = slugify(title, { lowercase: true }); + id, + data: { title, pubDate }, +} = entry; const articleLang = id.split("/")[0]; --- @@ -27,11 +23,7 @@ const articleLang = id.split("/")[0]; itemtype="http://schema.org/BlogPosting" class="article-item" > - +

{title}

{articleLang !== pageLang && {articleLang.toLocaleUpperCase()}} diff --git a/src/components/PageHeading.astro b/src/components/PageHeading.astro index ded384f..c7c3023 100644 --- a/src/components/PageHeading.astro +++ b/src/components/PageHeading.astro @@ -16,14 +16,13 @@ const { heading, description } = Astro.props as Props;