site-library/src/pages/index.astro
2025-03-12 18:53:16 +01:00

44 lines
1.2 KiB
Plaintext

---
import BaseLayout from "@/layouts/BaseLayout.astro"
import { getCollection } from "astro:content"
import StoreEntries from "@/components/store/StoreEntries.astro"
import CtaTwo from "@/components/cta/CtaTwo.astro"
const allProducts = await getCollection("store")
const locale = Astro.currentLocale || "en"
---
<BaseLayout>
<CtaTwo />
<section>
<div class="py-2 space-y-2">
<div class="grid md:grid-cols-2 lg:grid-cols-2 gap-2 ">
</div>
</div>
</section>
<section>
<div class="grid sm:grid-cols-2 lg:grid-cols-2 xl:grid-cols-2 gap-2">
{
allProducts.map((item) => (
<StoreEntries
url={ locale + "/store/" + item.id}
title={item.data.title}
price={item.data.price}
type={item.data.type}
alt={item.data.title}
model={item.data}
/>
))
}
</div>
</section>
{ <script>
const currentPath = window.location.pathname;
if (!/^\/[a-z]{2}(\/|$)/i.test(currentPath)) {
let language = navigator.language
language = language.split('-')[0]
language = "en"
window.location.href = `/${language}`;
}
</script>
</BaseLayout>