diff --git a/src/components/ui/cards/CardBlog.astro b/src/components/ui/cards/CardBlog.astro index b478245..732feac 100644 --- a/src/components/ui/cards/CardBlog.astro +++ b/src/components/ui/cards/CardBlog.astro @@ -1,52 +1,61 @@ --- import AvatarBlog from "../avatars/AvatarBlog.astro"; -import {Image} from "astro:assets"; +import { Image } from "astro:assets"; -import {formatDate} from "../../../utils"; -import type {CollectionEntry} from "astro:content"; +import { formatDate } from "../../../utils"; +import type { CollectionEntry } from "astro:content"; -const {blogEntry} = Astro.props; +const { blogEntry } = Astro.props; interface Props { - blogEntry: CollectionEntry<"blog">; + blogEntry: CollectionEntry<"blog">; } --- - -
- {blogEntry.data.cardImageAlt} -
+
+
+ {blogEntry.data.cardImageAlt} +
-
-
+
+
+
+ -
- - - -
-

- {blogEntry.data.author} -

-

- {formatDate(blogEntry.data.pubDate)} - -

-
-
+
+

+ {blogEntry.data.author} +

+

+ {formatDate(blogEntry.data.pubDate)} +

+
+
-
-
-

- {blogEntry.data.title} -

-

- {blogEntry.data.description} -

-
+
+ diff --git a/src/components/ui/cards/CardBlogRecent.astro b/src/components/ui/cards/CardBlogRecent.astro index cdfd9b5..73c02ae 100644 --- a/src/components/ui/cards/CardBlogRecent.astro +++ b/src/components/ui/cards/CardBlogRecent.astro @@ -1,8 +1,6 @@ --- - import { Image } from "astro:assets"; - import type { CollectionEntry } from "astro:content"; import AvatarBlogLarge from "../avatars/AvatarBlogLarge.astro"; import PrimaryCTA from "../buttons/PrimaryCTA.astro"; @@ -10,41 +8,54 @@ import PrimaryCTA from "../buttons/PrimaryCTA.astro"; const { blogEntry } = Astro.props; interface Props { - blogEntry: CollectionEntry<"blog">; + blogEntry: CollectionEntry<"blog">; } --- -
-
-
- {blogEntry.data.cardImageAlt} + +
+
+
+ {blogEntry.data.cardImageAlt} +
+
+ +
+

+ + {blogEntry.data.description} + +

+ +
+ + +
+

+ {blogEntry.data.author} +

+

+ {blogEntry.data.role} +

-
-

- - {blogEntry.data.description} - -

- - -
- - - -
-

- {blogEntry.data.author} -

-

- {blogEntry.data.role} -

-
-
- -
- -
+
+
- -
\ No newline at end of file +
+
diff --git a/src/content/config.ts b/src/content/config.ts index 77581b8..557d4e0 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -70,7 +70,19 @@ const blogCollection = defineCollection({ }), }); +const insightsCollection = defineCollection({ + type: "content", + schema: ({ image }) => z.object ({ + title: z.string(), + description: z.string(), + contents: z.array(z.string()), + cardImage: image(), + cardImageAlt: z.string(), + }), +}); + export const collections = { 'products': productsCollection, 'blog': blogCollection, + 'insights': insightsCollection, }; \ No newline at end of file diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index dedb47e..4d94cc6 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -1,12 +1,12 @@ --- // Import section components import MainLayout from "../../layouts/MainLayout.astro"; -import ProductTabBtn from "../../components/ui/buttons/ProductTabBtn.astro"; -import PrimaryCTA from "../../components/ui/buttons/PrimaryCTA.astro"; import AvatarBlogLarge from "../../components/ui/avatars/AvatarBlogLarge.astro"; +import CardRelated from "../../components/ui/cards/CardRelated.astro"; import { Image } from "astro:assets"; import { capitalize, formatDate } from "../../utils"; import { getCollection } from "astro:content"; +import type { CollectionEntry } from "astro:content"; export async function getStaticPaths() { const blogPosts = await getCollection("blog"); @@ -17,6 +17,11 @@ export async function getStaticPaths() { } const { post } = Astro.props; + +const blogPosts: CollectionEntry<"blog">[] = await getCollection("blog"); +const relatedPosts: CollectionEntry<"blog"> = blogPosts.filter( + (blogEntry) => blogEntry.slug !== post.slug, +); --- - - - {post.data.author} - - + + {post.data.author} +
-

+

{post.data.title}

-
+
{ - post.data.contents.map((content: string, index: any) => ( - index === 1 ? -

- {content} -

- {post.data.cardImageAlt} :

- {content} -

- )) + post.data.contents.map((content: string, index: any) => + index === 1 ? ( +

+ {content} +

+ {post.data.cardImageAlt} + ) : ( +

+ {content} +

+ ), + ) }
@@ -93,4 +103,18 @@ const { post } = Astro.props;
+ +
+
+

+ Related articles +

+
+ +
+ {relatedPosts.map((entry) => )} +
+
diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro index ec06b80..eb1e6a1 100644 --- a/src/pages/blog/index.astro +++ b/src/pages/blog/index.astro @@ -3,13 +3,19 @@ import MainLayout from "../../layouts/MainLayout.astro"; import CardBlog from "../../components/ui/cards/CardBlog.astro"; import CardBlogRecent from "../../components/ui/cards/CardBlogRecent.astro"; +import CardInsight from "../../components/ui/cards/CardInsight.astro"; +import { Image } from "astro:assets"; import { getCollection } from "astro:content"; import type { CollectionEntry } from "astro:content"; -const blogPosts: CollectionEntry<"blog">[] = ( - await getCollection("blog") -).sort((a: CollectionEntry<"blog">, b: CollectionEntry<"blog">) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf()); +const blogPosts: CollectionEntry<"blog">[] = (await getCollection("blog")).sort( + (a: CollectionEntry<"blog">, b: CollectionEntry<"blog">) => + b.data.pubDate.valueOf() - a.data.pubDate.valueOf(), +); + +const insightPosts: CollectionEntry<"insights">[] = + await getCollection("insights"); const mostRecentPost: CollectionEntry<"blog"> = blogPosts[0]; const otherPosts: CollectionEntry<"blog">[] = blogPosts.slice(1); @@ -22,112 +28,63 @@ const subTitle: string = const secondTitle: string = "Insights"; const secondSubTitle: string = - "Stay up-to-date with the latest trends and developments in the construction industry with insights from ScrewFast's team of industry experts. "; + "Stay up-to-date with the latest trends and developments in the construction industry with insights from ScrewFast's team of industry experts. "; --- - - - -
- - -
-

- {title} -

- -

{subTitle}

-
- - -
- -
- -
- - {otherPosts.map(blogEntry => ( - - ))} + +
+
+

+ {title} +

+ +

+ {subTitle} +

- -