fix: fix errors

This commit is contained in:
Emil Gulamov 2025-01-02 19:16:18 +04:00
parent a8c09361a9
commit ebaacb466a
4 changed files with 13 additions and 13 deletions

View file

@ -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}`;

View file

@ -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}`;
---

View file

@ -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}`;
---

View file

@ -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 },
};
});