From ebaacb466a56ab08fb01a60b7c6cc2ff01a8f9d0 Mon Sep 17 00:00:00 2001 From: Emil Gulamov <125820963+mearashadowfax@users.noreply.github.com> Date: Thu, 2 Jan 2025 19:16:18 +0400 Subject: [PATCH] fix: fix errors --- src/pages/blog/{[...slug].astro => [id].astro} | 6 +++--- src/pages/fr/insights/[...slug].astro | 8 ++++---- src/pages/insights/{[...slug].astro => [id].astro} | 8 ++++---- src/pages/products/{[...slug].astro => [id].astro} | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) rename src/pages/blog/{[...slug].astro => [id].astro} (97%) rename src/pages/insights/{[...slug].astro => [id].astro} (97%) rename src/pages/products/{[...slug].astro => [id].astro} (98%) diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[id].astro similarity index 97% rename from src/pages/blog/[...slug].astro rename to src/pages/blog/[id].astro index 957cf19..62a6c30 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[id].astro @@ -18,9 +18,9 @@ export async function getStaticPaths() { id.startsWith("en/") ); return blogPosts.map((post) => { - const slugWithoutLang = post.slug.replace(/^en\//, ""); // Remove the "en/" prefix + const slugWithoutLang = post.id.replace(/^en\//, ""); // Remove the "en/" prefix return { - params: { slug: slugWithoutLang }, + params: { id: slugWithoutLang }, props: { post }, }; }); @@ -39,7 +39,7 @@ const blogPosts: CollectionEntry<"blog">[] = await getCollection( // In a production site, you might want to implement a more robust algorithm, choosing related posts based on tags, categories, dates, authors, or keywords. // See example: https://blog.codybrunner.com/2024/adding-related-articles-with-astro-content-collections/ const relatedPosts: CollectionEntry<"blog">[] = blogPosts.filter( - (blogEntry) => blogEntry.slug !== post.slug + (blogEntry) => blogEntry.id !== post.id ); const pageTitle: string = `${post.data.title} | ${SITE.title}`; diff --git a/src/pages/fr/insights/[...slug].astro b/src/pages/fr/insights/[...slug].astro index 923da03..4973660 100644 --- a/src/pages/fr/insights/[...slug].astro +++ b/src/pages/fr/insights/[...slug].astro @@ -3,15 +3,15 @@ import { SITE } from "@data/constants"; import MainLayout from "@/layouts/MainLayout.astro"; import { Image } from "astro:assets"; -import { getCollection } from "astro:content"; +import { getCollection, render } from "astro:content"; // Use `getStaticPaths` to generate static routes for generated pages on build export async function getStaticPaths() { const insightPosts = await getCollection("insights", ({ id }) => id.startsWith("fr/")); return insightPosts.map((post) => { - const slugWithoutLang = post.slug.replace(/^fr\//, ''); // Remove the "fr/" prefix + const slugWithoutLang = post.id.replace(/^fr\//, ''); // Remove the "fr/" prefix return { - params: { lang: 'fr', slug: slugWithoutLang }, + params: { lang: 'fr', id: slugWithoutLang }, props: { post }, }; }); @@ -20,7 +20,7 @@ export async function getStaticPaths() { // Get the props for this page that define a specific insight post const { post } = Astro.props; -const { Content } = await post.render(); +const { Content } = await render(post); const pageTitle: string = `${post.data.title} | ${SITE.title}`; --- diff --git a/src/pages/insights/[...slug].astro b/src/pages/insights/[id].astro similarity index 97% rename from src/pages/insights/[...slug].astro rename to src/pages/insights/[id].astro index 4e57969..187b82f 100644 --- a/src/pages/insights/[...slug].astro +++ b/src/pages/insights/[id].astro @@ -3,7 +3,7 @@ import { SITE } from "@data/constants"; import MainLayout from "@/layouts/MainLayout.astro"; import { Image } from "astro:assets"; -import { getCollection } from "astro:content"; +import { getCollection, render } from "astro:content"; // Use `getStaticPaths` to generate static routes for generated pages on build export async function getStaticPaths() { @@ -11,9 +11,9 @@ export async function getStaticPaths() { id.startsWith("en/") ); return insightPosts.map((post) => { - const slugWithoutLang = post.slug.replace(/^en\//, ""); // Remove the "fr/" prefix + const slugWithoutLang = post.id.replace(/^en\//, ""); // Remove the "fr/" prefix return { - params: { slug: slugWithoutLang }, + params: { id: slugWithoutLang }, props: { post }, }; }); @@ -22,7 +22,7 @@ export async function getStaticPaths() { // Get the props for this page that define a specific insight post const { post } = Astro.props; -const { Content } = await post.render(); +const { Content } = await render(post); const pageTitle: string = `${post.data.title} | ${SITE.title}`; --- diff --git a/src/pages/products/[...slug].astro b/src/pages/products/[id].astro similarity index 98% rename from src/pages/products/[...slug].astro rename to src/pages/products/[id].astro index 3531558..732eea2 100644 --- a/src/pages/products/[...slug].astro +++ b/src/pages/products/[id].astro @@ -21,9 +21,9 @@ export async function getStaticPaths() { id.startsWith("en/") ); return productEntries.map((product) => { - const slugWithoutLang = product.slug.replace(/^en\//, ""); // Remove the "en/" prefix + const slugWithoutLang = product.id.replace(/^en\//, ""); // Remove the "en/" prefix return { - params: { slug: slugWithoutLang }, + params: { id: slugWithoutLang }, props: { product }, }; });