Skip to content

Commit

Permalink
Displaying home page in /index
Browse files Browse the repository at this point in the history
  • Loading branch information
Daveed committed Oct 30, 2024
1 parent c6153cf commit 6c1365b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/Breadcrumbs.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const currentUrlPath = Astro.url.pathname.replace(/\/+$/, "");
// Get url array from path
// eg: /tags/tailwindcss => ['tags', 'tailwindcss']
const breadcrumbList = currentUrlPath.split("/").slice(1);
const breadcrumbList = currentUrlPath?.split("/").slice(1) || [];
// if breadcrumb is Home > Posts > 1 <etc>
// replace Posts with Posts (page number)
Expand Down
21 changes: 17 additions & 4 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import getSortedPosts from "@utils/getSortedPosts";
import { SITE, SOCIALS } from "@config";
import { getCollection } from "astro:content";
import type Store from "../interfaces/Store";
import type Page from "../interfaces/Page";
import {
BlocksRenderer,
type BlocksContent,
} from "@strapi/blocks-react-renderer";
const stores = await getCollection("stores");
const store = stores?.[0]?.data as unknown as Store;
Expand All @@ -23,7 +28,10 @@ const recentPosts = sortedPosts.filter(({ data }) => !data.featured);
const socialCount = SOCIALS.filter(social => social.active).length;
const pages = await getCollection("pages");
const homePage = pages.find(
page => (page as unknown as { data: Page }).data.slug === "home"
) as unknown as { data: Page };
const links = store?.Links || [];
const products = store?.products?.data || [];
Expand Down Expand Up @@ -71,9 +79,14 @@ const products = store?.products?.data || [];
/>
)
}



</section>
<section class="">
<BlocksRenderer
content={homePage?.data?.Content || ([] as BlocksContent[])}
/>
</section>
<Hr />
<section>
{
links && links.length > 0 && (
<div class="mb-12 mt-6">
Expand Down

0 comments on commit 6c1365b

Please sign in to comment.