mirror of
https://github.com/10h30/astroplate.git
synced 2026-07-17 13:43:29 +09:00
tags pages added
This commit is contained in:
@@ -10,17 +10,17 @@ import config from "@/config/config.json";
|
||||
|
||||
export const getSinglePage = async <C extends CollectionKey>(
|
||||
collectionName: C,
|
||||
lang: keyof ContentEntryMap
|
||||
lang: keyof ContentEntryMap,
|
||||
): Promise<CollectionEntry<C>[]> => {
|
||||
const { defaultLang } = config.language;
|
||||
const { default_language } = config.settings;
|
||||
const langCollection: keyof ContentEntryMap = lang as keyof ContentEntryMap;
|
||||
|
||||
// Explicitly define the type of pages to CollectionEntry<C>[]
|
||||
const pages: CollectionEntry<C>[] = (await getCollection(
|
||||
langCollection || defaultLang,
|
||||
langCollection || default_language,
|
||||
({ id }: any) => {
|
||||
return id.startsWith(collectionName) && !id.endsWith("-index.md");
|
||||
}
|
||||
},
|
||||
)) as CollectionEntry<C>[];
|
||||
|
||||
const removeDrafts = pages.filter((data) => !data.data.draft);
|
||||
@@ -29,16 +29,16 @@ export const getSinglePage = async <C extends CollectionKey>(
|
||||
|
||||
export const getListPage = async <C extends CollectionKey>(
|
||||
collectionName: C,
|
||||
lang: keyof ContentEntryMap
|
||||
lang: keyof ContentEntryMap,
|
||||
): Promise<CollectionEntry<C>[]> => {
|
||||
const { defaultLang } = config.language;
|
||||
const { default_language } = config.settings;
|
||||
const langCollection: keyof ContentEntryMap = lang as keyof ContentEntryMap;
|
||||
// Fetch the collection based on the language
|
||||
const pages: CollectionEntry<C>[] = (await getCollection(
|
||||
langCollection || defaultLang,
|
||||
langCollection || default_language,
|
||||
({ id }: any) => {
|
||||
return id.startsWith(collectionName);
|
||||
}
|
||||
},
|
||||
)) as CollectionEntry<C>[];
|
||||
|
||||
return pages;
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
---
|
||||
import config from "@/config/config.json";
|
||||
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: any, name: string) => {
|
||||
// const singlePages = await getSinglePage(collection);
|
||||
const { default_language } = config.settings;
|
||||
const actualCollection =
|
||||
collection !== ("" || undefined) ? collection : default_language;
|
||||
|
||||
const singlePages = await getCollection(
|
||||
collection as keyof ContentEntryMap,
|
||||
actualCollection as keyof ContentEntryMap,
|
||||
({ id }: any) => {
|
||||
return id.startsWith("blog") && !id.endsWith("-index.md");
|
||||
}
|
||||
},
|
||||
);
|
||||
const taxonomyPages = singlePages.map((page: any) => page.data[name]);
|
||||
let taxonomies: string[] = [];
|
||||
@@ -26,12 +30,14 @@ export const getTaxonomy = async (collection: any, name: string) => {
|
||||
|
||||
// get all taxonomies from frontmatter
|
||||
export const getAllTaxonomy = async (collection: any, name: string) => {
|
||||
// const singlePages = await getSinglePage(collection);
|
||||
const { default_language } = config.settings;
|
||||
const actualCollection =
|
||||
collection !== ("" || undefined) ? collection : default_language;
|
||||
const singlePages = await getCollection(
|
||||
collection as keyof ContentEntryMap,
|
||||
actualCollection as keyof ContentEntryMap,
|
||||
({ id }: any) => {
|
||||
return id.startsWith("blog") && !id.endsWith("-index.md");
|
||||
}
|
||||
},
|
||||
);
|
||||
const taxonomyPages = singlePages.map((page: any) => page.data[name]);
|
||||
let taxonomies: string[] = [];
|
||||
|
||||
@@ -2,7 +2,7 @@ import config from "@/config/config.json";
|
||||
import languagesJSON from "@/config/language.json";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
const { defaultLang } = config.language;
|
||||
const { default_language } = config.settings;
|
||||
|
||||
const menusFolderPath = "./src/config";
|
||||
|
||||
@@ -30,12 +30,16 @@ export function getLangFromUrl(url: URL): string {
|
||||
if (locales.hasOwnProperty(lang)) {
|
||||
return lang;
|
||||
}
|
||||
return defaultLang;
|
||||
return default_language;
|
||||
}
|
||||
|
||||
export const getTranslations = async (lang: string) => {
|
||||
const menu = await import(`../../config/menu.${lang || defaultLang}.json`);
|
||||
const dictionary = await import(`../../i18n/${lang || defaultLang}.json`);
|
||||
const menu = await import(
|
||||
`../../config/menu.${lang || default_language}.json`
|
||||
);
|
||||
const dictionary = await import(
|
||||
`../../i18n/${lang || default_language}.json`
|
||||
);
|
||||
return { ...menu, ...dictionary };
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user