From e8171d327e6cd717ca4fc2c715b35d5dbb165ea2 Mon Sep 17 00:00:00 2001 From: satnaing Date: Sat, 28 Jan 2023 01:23:37 +0630 Subject: [PATCH] refactor: update for new content collection api --- src/pages/index.astro | 22 ++++++++++------------ src/pages/posts/[slug].astro | 17 ++++++++--------- src/pages/tags/[tag].astro | 19 +++++++------------ src/pages/tags/index.astro | 6 +++--- 4 files changed, 28 insertions(+), 36 deletions(-) diff --git a/src/pages/index.astro b/src/pages/index.astro index d216951..1b82def 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,22 +1,20 @@ --- +import { getCollection } from "astro:content"; import Layout from "@layouts/Layout.astro"; import Header from "@components/Header.astro"; import Footer from "@components/Footer.astro"; import LinkButton from "@components/LinkButton.astro"; import Hr from "@components/Hr.astro"; import Card from "@components/Card"; +import Socials from "@components/Socials.astro"; import getSortedPosts from "@utils/getSortedPosts"; import slugify from "@utils/slugify"; -import type { Frontmatter } from "src/types"; -import Socials from "@components/Socials.astro"; import { SOCIALS } from "@config"; -const posts = await Astro.glob("../contents/**/*.md"); +const posts = await getCollection("blog"); const sortedPosts = getSortedPosts(posts); -const featuredPosts = sortedPosts.filter( - ({ frontmatter }) => frontmatter.featured -); +const featuredPosts = sortedPosts.filter(({ data }) => data.featured); const socialCount = SOCIALS.filter(social => social.active).length; --- @@ -76,10 +74,10 @@ const socialCount = SOCIALS.filter(social => social.active).length;