From b4f128b6e2746d3505922ff467b3efe4bc0409d3 Mon Sep 17 00:00:00 2001 From: Emil Gulamov <125820963+mearashadowfax@users.noreply.github.com> Date: Sun, 17 Mar 2024 08:04:59 +0400 Subject: [PATCH] Add Bookmark button functionality and update blog post layout This commit introduces a new Bookmark button component along with its corresponding functionality using localStorage. It also updates the blog post layout by adding the Bookmark button, SocialShare, and PostFeedback components as well as restructuring the post tags section for better UI. --- src/components/ui/buttons/Bookmark.astro | 104 +++++++++++++++++++++++ src/pages/blog/[...slug].astro | 48 ++++++++--- 2 files changed, 141 insertions(+), 11 deletions(-) create mode 100644 src/components/ui/buttons/Bookmark.astro diff --git a/src/components/ui/buttons/Bookmark.astro b/src/components/ui/buttons/Bookmark.astro new file mode 100644 index 0000000..0c8ae2c --- /dev/null +++ b/src/components/ui/buttons/Bookmark.astro @@ -0,0 +1,104 @@ + + + diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index f9c80bf..a62d2c7 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -3,6 +3,9 @@ import MainLayout from "../../layouts/MainLayout.astro"; import AvatarBlogLarge from "../../components/ui/avatars/AvatarBlogLarge.astro"; import CardRelated from "../../components/ui/cards/CardRelated.astro"; +import Bookmark from "../../components/ui/buttons/Bookmark.astro"; +import SocialShare from "../../components/ui/buttons/SocialShare.astro"; +import PostFeedback from "../../components/ui/feedback/PostFeedback.astro"; import { Image } from "astro:assets"; import { capitalize, formatDate } from "../../utils/utils"; import { getCollection } from "astro:content"; @@ -27,7 +30,7 @@ const blogPosts: CollectionEntry<"blog">[] = await getCollection("blog"); // In a production site, you might want to implement a more robust algorithm, choosing related posts based on tags, categories, dates, authors, or keywords. // See example: https://blog.codybrunner.com/2024/adding-related-articles-with-astro-content-collections/ const relatedPosts: CollectionEntry<"blog">[] = blogPosts.filter( - (blogEntry) => blogEntry.slug !== post.slug, + (blogEntry) => blogEntry.slug !== post.slug ); --- @@ -94,22 +97,45 @@ const relatedPosts: CollectionEntry<"blog">[] = blogPosts.filter(

{content}

- ), + ) ) } - -
- { - post.data.tags?.map((tag: string) => ( - - {capitalize(tag)} - - )) - } +
+ +
+ { + post.data.tags?.map((tag: string, index) => ( + + {capitalize(tag)} + + )) + } +
+ +
+ +
+
+
+ +
+
+ +