content folder name chanded && fn added

This commit is contained in:
Al Murad Uzzaman
2024-05-18 22:20:40 +06:00
parent 76f1b5b6c1
commit 742c67c3d5
9 changed files with 87 additions and 86 deletions
+2 -5
View File
@@ -4,8 +4,7 @@ import Base from "@/layouts/Base.astro";
import { getListPage } from "@/lib/contentParser.astro";
import { supportedLang } from "@/lib/utils/i18nUtils";
import { markdownify } from "@/lib/utils/textConverter";
import type { ContentEntryMap } from "astro:content";
import type { ContentCollectionKey } from "astro:content";
import type { ContentCollectionKey, ContentEntryMap } from "astro:content";
export function getStaticPaths() {
const paths = supportedLang.map((lang) => ({
@@ -17,11 +16,9 @@ export function getStaticPaths() {
const { lang } = Astro.params;
const about: any = await getListPage(
"about" as ContentCollectionKey,
lang as keyof ContentEntryMap
lang as keyof ContentEntryMap,
);
console.log(about);
const { Content } = await about[0].render();
const { title, description, meta_title, image } = about[0].data;
---
+11 -14
View File
@@ -3,6 +3,7 @@ import BlogCard from "@/components/BlogCard.astro";
import Pagination from "@/components/Pagination.astro";
import config from "@/config/config.json";
import Base from "@/layouts/Base.astro";
import { getListPage, getSinglePage } from "@/lib/contentParser.astro";
import { getAllTaxonomy, getTaxonomy } from "@/lib/taxonomyParser.astro";
import { supportedLang } from "@/lib/utils/i18nUtils";
import { sortByDate } from "@/lib/utils/sortFunctions";
@@ -14,24 +15,20 @@ const BLOG_FOLDER = "blog";
const { slug, lang } = Astro.params;
const postIndex: any = await getCollection(
const postIndex: any = await getListPage(
BLOG_FOLDER,
lang as keyof ContentEntryMap,
({ id }: any) => {
return id.startsWith(BLOG_FOLDER);
},
);
const posts = await getCollection(
const posts = await getSinglePage(BLOG_FOLDER, lang as keyof ContentEntryMap);
const allCategories = await getAllTaxonomy(
lang as keyof ContentEntryMap,
({ id }: any) => {
return id.startsWith(BLOG_FOLDER) && !id.endsWith("-index.md");
},
"categories",
);
const langCollection: keyof ContentEntryMap = lang as keyof ContentEntryMap;
const allCategories = await getAllTaxonomy(langCollection, "categories");
const categories = await getTaxonomy(langCollection, "categories");
const tags = await getTaxonomy(langCollection, "tags");
const categories = await getTaxonomy(
lang as keyof ContentEntryMap,
"categories",
);
const tags = await getTaxonomy(lang as keyof ContentEntryMap, "tags");
const sortedPosts = sortByDate(posts);
const totalPages = Math.ceil(posts.length / config.settings.pagination);
const currentPage = slug && !isNaN(Number(slug)) ? Number(slug) : 1;
@@ -16,7 +16,10 @@ export async function getStaticPaths() {
const paths = await Promise.all(
supportedLang.map(async (lang) => {
const categories = await getTaxonomy(lang, "categories");
const categories = await getTaxonomy(
lang as keyof ContentEntryMap,
"categories",
);
return categories.map((category) => ({
params: {
@@ -27,11 +30,14 @@ export async function getStaticPaths() {
category,
},
}));
})
}),
);
// Handle default path (no lang)
const defaultCategories = await getTaxonomy(default_language, "categories");
const defaultCategories = await getTaxonomy(
default_language as keyof ContentEntryMap,
"categories",
);
const defaultPaths = defaultCategories.map((category) => ({
params: {
lang: undefined,
+8 -14
View File
@@ -2,14 +2,13 @@
import ImageMod from "@/components/ImageMod.astro";
import config from "@/config/config.json";
import Base from "@/layouts/Base.astro";
import { getListPage } from "@/lib/contentParser.astro";
import { getListPage, getSinglePage } from "@/lib/contentParser.astro";
import { supportedLang } from "@/lib/utils/i18nUtils";
import { markdownify } from "@/lib/utils/textConverter";
import CallToAction from "@/partials/CallToAction.astro";
import Testimonial from "@/partials/Testimonial.astro";
import type { Button, Feature } from "@/types";
import type { ContentCollectionKey, ContentEntryMap } from "astro:content";
import { getCollection } from "astro:content";
import { FaCheck } from "react-icons/fa";
const { default_language } = config.settings;
@@ -37,19 +36,14 @@ const homepage: any = await getListPage(
);
const { banner, features } = homepage[0].data;
const testimonial = await getCollection(
(lang as keyof ContentEntryMap) || default_language,
({ id }: any) => {
return id.startsWith("sections/testimonial") && !id.endsWith("-index.md");
},
const testimonial = await getSinglePage(
"sections/testimonial" as ContentCollectionKey,
lang as keyof ContentEntryMap,
);
const call_to_action = await getCollection(
(lang as keyof ContentEntryMap) || default_language,
({ id }: any) => {
return (
id.startsWith("sections/call-to-action") && !id.endsWith("-index.md")
);
},
const call_to_action = await getSinglePage(
"sections/call-to-action" as ContentCollectionKey,
lang as keyof ContentEntryMap,
);
---
+6 -3
View File
@@ -16,7 +16,7 @@ export async function getStaticPaths() {
const paths = await Promise.all(
supportedLang.map(async (lang) => {
const tags = await getTaxonomy(lang, "tags");
const tags = await getTaxonomy(lang as keyof ContentEntryMap, "tags");
return tags.map((tag) => ({
params: {
@@ -27,11 +27,14 @@ export async function getStaticPaths() {
tag,
},
}));
})
}),
);
// Handle default path (no lang)
const defaultCategories = await getTaxonomy(default_language, "tags");
const defaultCategories = await getTaxonomy(
default_language as keyof ContentEntryMap,
"tags",
);
const defaultPaths = defaultCategories.map((tag) => ({
params: {
lang: undefined,