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/") id.startsWith("en/")
); );
return blogPosts.map((post) => { 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 { return {
params: { slug: slugWithoutLang }, params: { id: slugWithoutLang },
props: { post }, 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. // 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/ // See example: https://blog.codybrunner.com/2024/adding-related-articles-with-astro-content-collections/
const relatedPosts: CollectionEntry<"blog">[] = blogPosts.filter( const relatedPosts: CollectionEntry<"blog">[] = blogPosts.filter(
(blogEntry) => blogEntry.slug !== post.slug (blogEntry) => blogEntry.id !== post.id
); );
const pageTitle: string = `${post.data.title} | ${SITE.title}`; const pageTitle: string = `${post.data.title} | ${SITE.title}`;

View file

@ -3,15 +3,15 @@
import { SITE } from "@data/constants"; import { SITE } from "@data/constants";
import MainLayout from "@/layouts/MainLayout.astro"; import MainLayout from "@/layouts/MainLayout.astro";
import { Image } from "astro:assets"; 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 // Use `getStaticPaths` to generate static routes for generated pages on build
export async function getStaticPaths() { export async function getStaticPaths() {
const insightPosts = await getCollection("insights", ({ id }) => id.startsWith("fr/")); const insightPosts = await getCollection("insights", ({ id }) => id.startsWith("fr/"));
return insightPosts.map((post) => { 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 { return {
params: { lang: 'fr', slug: slugWithoutLang }, params: { lang: 'fr', id: slugWithoutLang },
props: { post }, props: { post },
}; };
}); });
@ -20,7 +20,7 @@ export async function getStaticPaths() {
// Get the props for this page that define a specific insight post // Get the props for this page that define a specific insight post
const { post } = Astro.props; const { post } = Astro.props;
const { Content } = await post.render(); const { Content } = await render(post);
const pageTitle: string = `${post.data.title} | ${SITE.title}`; const pageTitle: string = `${post.data.title} | ${SITE.title}`;
--- ---

View file

@ -3,7 +3,7 @@
import { SITE } from "@data/constants"; import { SITE } from "@data/constants";
import MainLayout from "@/layouts/MainLayout.astro"; import MainLayout from "@/layouts/MainLayout.astro";
import { Image } from "astro:assets"; 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 // Use `getStaticPaths` to generate static routes for generated pages on build
export async function getStaticPaths() { export async function getStaticPaths() {
@ -11,9 +11,9 @@ export async function getStaticPaths() {
id.startsWith("en/") id.startsWith("en/")
); );
return insightPosts.map((post) => { 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 { return {
params: { slug: slugWithoutLang }, params: { id: slugWithoutLang },
props: { post }, props: { post },
}; };
}); });
@ -22,7 +22,7 @@ export async function getStaticPaths() {
// Get the props for this page that define a specific insight post // Get the props for this page that define a specific insight post
const { post } = Astro.props; const { post } = Astro.props;
const { Content } = await post.render(); const { Content } = await render(post);
const pageTitle: string = `${post.data.title} | ${SITE.title}`; const pageTitle: string = `${post.data.title} | ${SITE.title}`;
--- ---

View file

@ -21,9 +21,9 @@ export async function getStaticPaths() {
id.startsWith("en/") id.startsWith("en/")
); );
return productEntries.map((product) => { 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 { return {
params: { slug: slugWithoutLang }, params: { id: slugWithoutLang },
props: { product }, props: { product },
}; };
}); });