remove multilingual and create a new multilingual branch

This commit is contained in:
Somrat
2024-11-18 09:55:18 +06:00
parent b092921209
commit f7bc32a629
82 changed files with 453 additions and 1928 deletions
+5 -50
View File
@@ -1,34 +1,10 @@
---
import config from "@/config/config.json";
import languages from "@/config/language.json";
import { getSinglePage } from "@/lib/contentParser.astro";
import { slugify } from "@/lib/utils/textConverter";
import type { ContentEntryMap } from "astro:content";
import { getCollection } from "astro:content";
// get taxonomy from frontmatter
export const getTaxonomy = async (collection: string, name: string) => {
const { default_language } = config.settings;
const language = languages.find((l) => l.languageCode === collection);
let actualCollection = default_language;
if (language) {
actualCollection = language.contentDir;
} else {
const defaultLanguageMatch = languages.find(
(l) => l.languageCode === default_language
);
if (defaultLanguageMatch) {
actualCollection = defaultLanguageMatch.contentDir;
}
}
const singlePages = await getCollection(
"blog" as keyof ContentEntryMap,
({ id }: any) => {
return id.startsWith(actualCollection) && !id.endsWith("-index.md");
}
);
export const getTaxonomy = async (collection: any, name: string) => {
const singlePages = await getSinglePage(collection);
const taxonomyPages = singlePages.map((page: any) => page.data[name]);
let taxonomies: string[] = [];
for (let i = 0; i < taxonomyPages.length; i++) {
@@ -42,29 +18,8 @@ export const getTaxonomy = async (collection: string, name: string) => {
};
// get all taxonomies from frontmatter
export const getAllTaxonomy = async (collection: string, name: string) => {
const { default_language } = config.settings;
const language = languages.find((l) => l.languageCode === collection);
let actualCollection = default_language;
if (language) {
actualCollection = language.contentDir;
} else {
const defaultLanguageMatch = languages.find(
(l) => l.languageCode === default_language
);
if (defaultLanguageMatch) {
actualCollection = defaultLanguageMatch.contentDir;
}
}
const singlePages = await getCollection(
"blog" as keyof ContentEntryMap,
({ id }: any) => {
return id.startsWith(actualCollection) && !id.endsWith("-index.md");
}
);
export const getAllTaxonomy = async (collection: any, name: string) => {
const singlePages = await getSinglePage(collection);
const taxonomyPages = singlePages.map((page: any) => page.data[name]);
let taxonomies: string[] = [];
for (let i = 0; i < taxonomyPages.length; i++) {