mirror of
https://github.com/10h30/astroplate.git
synced 2026-07-17 05:33:28 +09:00
remove multilingual and create a new multilingual branch
This commit is contained in:
@@ -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++) {
|
||||
|
||||
Reference in New Issue
Block a user