From c735556726e75428550a3d28a2cf58e2c8490b7d Mon Sep 17 00:00:00 2001 From: Dawid Rycerz Date: Mon, 21 Jul 2025 21:56:55 +0300 Subject: Initial template --- src/components/blog/Grid.astro | 14 ++++ src/components/blog/GridItem.astro | 71 +++++++++++++++++++ src/components/blog/Headline.astro | 12 ++++ src/components/blog/List.astro | 20 ++++++ src/components/blog/ListItem.astro | 120 +++++++++++++++++++++++++++++++++ src/components/blog/Pagination.astro | 36 ++++++++++ src/components/blog/RelatedPosts.astro | 31 +++++++++ src/components/blog/SinglePost.astro | 103 ++++++++++++++++++++++++++++ src/components/blog/Tags.astro | 43 ++++++++++++ src/components/blog/ToBlogLink.astro | 20 ++++++ 10 files changed, 470 insertions(+) create mode 100644 src/components/blog/Grid.astro create mode 100644 src/components/blog/GridItem.astro create mode 100644 src/components/blog/Headline.astro create mode 100644 src/components/blog/List.astro create mode 100644 src/components/blog/ListItem.astro create mode 100644 src/components/blog/Pagination.astro create mode 100644 src/components/blog/RelatedPosts.astro create mode 100644 src/components/blog/SinglePost.astro create mode 100644 src/components/blog/Tags.astro create mode 100644 src/components/blog/ToBlogLink.astro (limited to 'src/components/blog') diff --git a/src/components/blog/Grid.astro b/src/components/blog/Grid.astro new file mode 100644 index 0000000..1b62be4 --- /dev/null +++ b/src/components/blog/Grid.astro @@ -0,0 +1,14 @@ +--- +import Item from '~/components/blog/GridItem.astro'; +import type { Post } from '~/types'; + +export interface Props { + posts: Array; +} + +const { posts } = Astro.props; +--- + +
+ {posts.map((post) => )} +
diff --git a/src/components/blog/GridItem.astro b/src/components/blog/GridItem.astro new file mode 100644 index 0000000..cd02fa8 --- /dev/null +++ b/src/components/blog/GridItem.astro @@ -0,0 +1,71 @@ +--- +import { APP_BLOG } from 'astrowind:config'; +import type { Post } from '~/types'; + +import Image from '~/components/common/Image.astro'; + +import { findImage } from '~/utils/images'; +import { getPermalink } from '~/utils/permalinks'; + +export interface Props { + post: Post; +} + +const { post } = Astro.props; +const image = await findImage(post.image); + +const link = APP_BLOG?.post?.isEnabled ? getPermalink(post.permalink, 'post') : ''; +--- + +
+
+ { + image && + (link ? ( + + {post.title} + + ) : ( + {post.title} + )) + } +
+ +

+ { + link ? ( + + {post.title} + + ) : ( + post.title + ) + } +

+ +

{post.excerpt}

+
diff --git a/src/components/blog/Headline.astro b/src/components/blog/Headline.astro new file mode 100644 index 0000000..5d3ccc6 --- /dev/null +++ b/src/components/blog/Headline.astro @@ -0,0 +1,12 @@ +--- +const { title = await Astro.slots.render('default'), subtitle = await Astro.slots.render('subtitle') } = Astro.props; +--- + +
+

+ { + subtitle && ( +
+ ) + } +

diff --git a/src/components/blog/List.astro b/src/components/blog/List.astro new file mode 100644 index 0000000..6a80ae3 --- /dev/null +++ b/src/components/blog/List.astro @@ -0,0 +1,20 @@ +--- +import Item from '~/components/blog/ListItem.astro'; +import type { Post } from '~/types'; + +export interface Props { + posts: Array; +} + +const { posts } = Astro.props; +--- + +
    + { + posts.map((post) => ( +
  • + +
  • + )) + } +
diff --git a/src/components/blog/ListItem.astro b/src/components/blog/ListItem.astro new file mode 100644 index 0000000..6a416d6 --- /dev/null +++ b/src/components/blog/ListItem.astro @@ -0,0 +1,120 @@ +--- +import type { ImageMetadata } from 'astro'; +import { Icon } from 'astro-icon/components'; +import Image from '~/components/common/Image.astro'; +import PostTags from '~/components/blog/Tags.astro'; + +import { APP_BLOG } from 'astrowind:config'; +import type { Post } from '~/types'; + +import { getPermalink } from '~/utils/permalinks'; +import { findImage } from '~/utils/images'; +import { getFormattedDate } from '~/utils/utils'; + +export interface Props { + post: Post; +} + +const { post } = Astro.props; +const image = (await findImage(post.image)) as ImageMetadata | undefined; + +const link = APP_BLOG?.post?.isEnabled ? getPermalink(post.permalink, 'post') : ''; +--- + +
+ { + image && + (link ? ( + + + + ) : ( + + )) + } +
+
+
+ + + + { + post.author && ( + <> + {' '} + · + {post.author.replaceAll('-', ' ')} + + ) + } + { + post.category && ( + <> + {' '} + ·{' '} + + {post.category.title} + + + ) + } + +
+

+ { + link ? ( + + {post.title} + + ) : ( + post.title + ) + } +

+
+ + {post.excerpt &&

{post.excerpt}

} + { + post.tags && Array.isArray(post.tags) ? ( +
+ +
+ ) : ( + + ) + } +
+
diff --git a/src/components/blog/Pagination.astro b/src/components/blog/Pagination.astro new file mode 100644 index 0000000..051587c --- /dev/null +++ b/src/components/blog/Pagination.astro @@ -0,0 +1,36 @@ +--- +import { Icon } from 'astro-icon/components'; +import { getPermalink } from '~/utils/permalinks'; +import Button from '~/components/ui/Button.astro'; + +export interface Props { + prevUrl?: string; + nextUrl?: string; + prevText?: string; + nextText?: string; +} + +const { prevUrl, nextUrl, prevText = 'Newer posts', nextText = 'Older posts' } = Astro.props; +--- + +{ + (prevUrl || nextUrl) && ( +
+
+ + + +
+
+ ) +} diff --git a/src/components/blog/RelatedPosts.astro b/src/components/blog/RelatedPosts.astro new file mode 100644 index 0000000..f4036e9 --- /dev/null +++ b/src/components/blog/RelatedPosts.astro @@ -0,0 +1,31 @@ +--- +import { APP_BLOG } from 'astrowind:config'; + +import { getRelatedPosts } from '~/utils/blog'; +import BlogHighlightedPosts from '../widgets/BlogHighlightedPosts.astro'; +import type { Post } from '~/types'; +import { getBlogPermalink } from '~/utils/permalinks'; + +export interface Props { + post: Post; +} + +const { post } = Astro.props; + +const relatedPosts = post.tags ? await getRelatedPosts(post, 4) : []; +--- + +{ + APP_BLOG.isRelatedPostsEnabled ? ( + post.id)} + /> + ) : null +} diff --git a/src/components/blog/SinglePost.astro b/src/components/blog/SinglePost.astro new file mode 100644 index 0000000..297cca9 --- /dev/null +++ b/src/components/blog/SinglePost.astro @@ -0,0 +1,103 @@ +--- +import { Icon } from 'astro-icon/components'; + +import Image from '~/components/common/Image.astro'; +import PostTags from '~/components/blog/Tags.astro'; +import SocialShare from '~/components/common/SocialShare.astro'; + +import { getPermalink } from '~/utils/permalinks'; +import { getFormattedDate } from '~/utils/utils'; + +import type { Post } from '~/types'; + +export interface Props { + post: Post; + url: string | URL; +} + +const { post, url } = Astro.props; +--- + +
+
+
+
+

+ + + { + post.author && ( + <> + {' '} + · + {post.author} + + ) + } + { + post.category && ( + <> + {' '} + ·{' '} + + {post.category.title} + + + ) + } + { + post.readingTime && ( + <> +  · {post.readingTime} min read + + ) + } +

+
+ +

+ {post.title} +

+

+ {post.excerpt} +

+ + { + post.image ? ( + {post?.excerpt + ) : ( +
+
+
+ ) + } +
+
+ +
+
+ + +
+
+
diff --git a/src/components/blog/Tags.astro b/src/components/blog/Tags.astro new file mode 100644 index 0000000..ae46a24 --- /dev/null +++ b/src/components/blog/Tags.astro @@ -0,0 +1,43 @@ +--- +import { getPermalink } from '~/utils/permalinks'; + +import { APP_BLOG } from 'astrowind:config'; +import type { Post } from '~/types'; + +export interface Props { + tags: Post['tags']; + class?: string; + title?: string | undefined; + isCategory?: boolean; +} + +const { tags, class: className = 'text-sm', title = undefined, isCategory = false } = Astro.props; +--- + +{ + tags && Array.isArray(tags) && ( + <> + {title !== undefined && ( + + {title} + + )} +
    + {tags.map((tag) => ( +
  • + {!APP_BLOG?.tag?.isEnabled ? ( + tag.title + ) : ( + + {tag.title} + + )} +
  • + ))} +
+ + ) +} diff --git a/src/components/blog/ToBlogLink.astro b/src/components/blog/ToBlogLink.astro new file mode 100644 index 0000000..7fb7a49 --- /dev/null +++ b/src/components/blog/ToBlogLink.astro @@ -0,0 +1,20 @@ +--- +import { Icon } from 'astro-icon/components'; +import { getBlogPermalink } from '~/utils/permalinks'; +import { I18N } from 'astrowind:config'; +import Button from '~/components/ui/Button.astro'; + +const { textDirection } = I18N; +--- + +
+ +
-- cgit v1.2.3