mirror of
https://github.com/10h30/astroplate.git
synced 2026-07-17 13:43:29 +09:00
i18nUtils renamed with languageParser
This commit is contained in:
+2
-2
@@ -1,12 +1,12 @@
|
||||
---
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { slugSelector } from "@/lib/languageParser.astro";
|
||||
import {
|
||||
getLangFromUrl,
|
||||
getTranslations,
|
||||
supportedLang,
|
||||
} from "@/lib/utils/i18nUtils";
|
||||
slugSelector,
|
||||
} from "@/lib/utils/languageParser";
|
||||
import type { ContentEntryMap } from "astro:content";
|
||||
|
||||
export function getStaticPaths() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import { supportedLang } from "@/lib/utils/i18nUtils";
|
||||
import { supportedLang } from "@/lib/utils/languageParser";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import type { ContentEntryMap } from "astro:content";
|
||||
|
||||
@@ -19,7 +19,7 @@ export async function getStaticPaths() {
|
||||
page,
|
||||
},
|
||||
}));
|
||||
}),
|
||||
})
|
||||
);
|
||||
return paths.flat();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import ImageMod from "@/components/ImageMod.astro";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getListPage } from "@/lib/contentParser.astro";
|
||||
import { supportedLang } from "@/lib/utils/i18nUtils";
|
||||
import { supportedLang } from "@/lib/utils/languageParser";
|
||||
import { markdownify } from "@/lib/utils/textConverter";
|
||||
import type { ContentCollectionKey, ContentEntryMap } from "astro:content";
|
||||
|
||||
@@ -16,7 +16,7 @@ export function getStaticPaths() {
|
||||
const { lang } = Astro.params;
|
||||
const about: any = await getListPage(
|
||||
"about" as ContentCollectionKey,
|
||||
lang as keyof ContentEntryMap,
|
||||
lang as keyof ContentEntryMap
|
||||
);
|
||||
|
||||
const { Content } = await about[0].render();
|
||||
|
||||
@@ -4,7 +4,7 @@ import ImageMod from "@/components/ImageMod.astro";
|
||||
import Social from "@/components/Social.astro";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import { supportedLang } from "@/lib/utils/i18nUtils";
|
||||
import { supportedLang } from "@/lib/utils/languageParser";
|
||||
import { slugify } from "@/lib/utils/textConverter";
|
||||
import type { ContentEntryMap } from "astro:content";
|
||||
|
||||
@@ -14,12 +14,12 @@ export async function getStaticPaths() {
|
||||
|
||||
const paths = await Promise.all(
|
||||
supportedLang.map(async (lang) => {
|
||||
const authors = await getSinglePage(
|
||||
const authors: any = await getSinglePage(
|
||||
COLLECTION_FOLDER,
|
||||
lang as keyof ContentEntryMap
|
||||
);
|
||||
|
||||
return authors.map((author) => ({
|
||||
return authors.map((author: any) => ({
|
||||
params: {
|
||||
lang: lang || undefined,
|
||||
single: author.slug.split("/").pop(),
|
||||
@@ -42,7 +42,7 @@ const { Content } = await author.render();
|
||||
const BLOG_FOLDER = "blog";
|
||||
const posts = await getSinglePage(BLOG_FOLDER, lang as keyof ContentEntryMap);
|
||||
const postFilterByAuthor = posts.filter(
|
||||
(post) => slugify(post.data.author) === slugify(title)
|
||||
(post: any) => slugify(post.data.author) === slugify(title)
|
||||
);
|
||||
---
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import AuthorCard from "@/components/AuthorCard.astro";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getListPage, getSinglePage } from "@/lib/contentParser.astro";
|
||||
import { supportedLang } from "@/lib/utils/i18nUtils";
|
||||
import { supportedLang } from "@/lib/utils/languageParser";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import { type ContentEntryMap } from "astro:content";
|
||||
|
||||
@@ -18,11 +18,11 @@ export function getStaticPaths() {
|
||||
const { lang } = Astro.params;
|
||||
const authorIndex: any = await getListPage(
|
||||
COLLECTION_FOLDER,
|
||||
lang as keyof ContentEntryMap,
|
||||
lang as keyof ContentEntryMap
|
||||
);
|
||||
const authors = await getSinglePage(
|
||||
COLLECTION_FOLDER,
|
||||
lang as keyof ContentEntryMap,
|
||||
lang as keyof ContentEntryMap
|
||||
);
|
||||
---
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import PostSingle from "@/layouts/PostSingle.astro";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import { supportedLang } from "@/lib/utils/i18nUtils";
|
||||
import { supportedLang } from "@/lib/utils/languageParser";
|
||||
import type { ContentEntryMap } from "astro:content";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
|
||||
@@ -5,7 +5,7 @@ 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 { supportedLang } from "@/lib/utils/languageParser";
|
||||
import { sortByDate } from "@/lib/utils/sortFunctions";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import PostSidebar from "@/partials/PostSidebar.astro";
|
||||
|
||||
@@ -5,7 +5,7 @@ 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 { supportedLang } from "@/lib/utils/languageParser";
|
||||
import { sortByDate } from "@/lib/utils/sortFunctions";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import PostSidebar from "@/partials/PostSidebar.astro";
|
||||
@@ -21,16 +21,16 @@ if (!lang) {
|
||||
|
||||
const postIndex: any = await getListPage(
|
||||
BLOG_FOLDER,
|
||||
lang as keyof ContentEntryMap,
|
||||
lang as keyof ContentEntryMap
|
||||
);
|
||||
const posts = await getSinglePage(BLOG_FOLDER, lang as keyof ContentEntryMap);
|
||||
const allCategories = await getAllTaxonomy(
|
||||
lang as keyof ContentEntryMap,
|
||||
"categories",
|
||||
"categories"
|
||||
);
|
||||
const categories = await getTaxonomy(
|
||||
lang as keyof ContentEntryMap,
|
||||
"categories",
|
||||
"categories"
|
||||
);
|
||||
const tags = await getTaxonomy(lang as keyof ContentEntryMap, "tags");
|
||||
const sortedPosts = sortByDate(posts);
|
||||
@@ -47,7 +47,7 @@ export async function getStaticPaths() {
|
||||
supportedLang.map(async (lang) => {
|
||||
const posts = await getSinglePage(
|
||||
BLOG_FOLDER,
|
||||
lang as keyof ContentEntryMap,
|
||||
lang as keyof ContentEntryMap
|
||||
);
|
||||
const totalPages = Math.ceil(posts.length / config.settings.pagination);
|
||||
const langString = lang.toString();
|
||||
@@ -63,7 +63,7 @@ export async function getStaticPaths() {
|
||||
}
|
||||
|
||||
return langPaths;
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
return paths.flat();
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
---
|
||||
import BlogCard from "@/components/BlogCard.astro";
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import { getTaxonomy } from "@/lib/taxonomyParser.astro";
|
||||
import { supportedLang } from "@/lib/utils/i18nUtils";
|
||||
import { supportedLang } from "@/lib/utils/languageParser";
|
||||
import { sortByDate } from "@/lib/utils/sortFunctions";
|
||||
import taxonomyFilter from "@/lib/utils/taxonomyFilter";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import type { ContentEntryMap } from "astro:content";
|
||||
import config from "@/config/config.json";
|
||||
|
||||
// get all static paths for categories
|
||||
export async function getStaticPaths() {
|
||||
@@ -18,7 +18,7 @@ export async function getStaticPaths() {
|
||||
supportedLang.map(async (lang) => {
|
||||
const categories = await getTaxonomy(
|
||||
lang as keyof ContentEntryMap,
|
||||
"categories",
|
||||
"categories"
|
||||
);
|
||||
|
||||
return categories.map((category) => ({
|
||||
@@ -30,13 +30,13 @@ export async function getStaticPaths() {
|
||||
category,
|
||||
},
|
||||
}));
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
// Handle default path (no lang)
|
||||
const defaultCategories = await getTaxonomy(
|
||||
default_language as keyof ContentEntryMap,
|
||||
"categories",
|
||||
"categories"
|
||||
);
|
||||
const defaultPaths = defaultCategories.map((category) => ({
|
||||
params: {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
---
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { slugSelector } from "@/lib/languageParser.astro";
|
||||
import { getAllTaxonomy, getTaxonomy } from "@/lib/taxonomyParser.astro";
|
||||
import { supportedLang } from "@/lib/utils/i18nUtils";
|
||||
import { slugSelector, supportedLang } from "@/lib/utils/languageParser";
|
||||
import { humanize } from "@/lib/utils/textConverter";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import type { ContentEntryMap } from "astro:content";
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getListPage } from "@/lib/contentParser.astro";
|
||||
import { getTranslations, supportedLang } from "@/lib/utils/i18nUtils";
|
||||
import { getTranslations, supportedLang } from "@/lib/utils/languageParser";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import type { CollectionKey } from "astro:content";
|
||||
import { type ContentEntryMap } from "astro:content";
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import ImageMod from "@/components/ImageMod.astro";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getListPage, getSinglePage } from "@/lib/contentParser.astro";
|
||||
import { supportedLang } from "@/lib/utils/i18nUtils";
|
||||
import { supportedLang } from "@/lib/utils/languageParser";
|
||||
import { markdownify } from "@/lib/utils/textConverter";
|
||||
import CallToAction from "@/partials/CallToAction.astro";
|
||||
import Testimonial from "@/partials/Testimonial.astro";
|
||||
|
||||
@@ -4,7 +4,7 @@ import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import { getTaxonomy } from "@/lib/taxonomyParser.astro";
|
||||
import { supportedLang } from "@/lib/utils/i18nUtils";
|
||||
import { supportedLang } from "@/lib/utils/languageParser";
|
||||
import { sortByDate } from "@/lib/utils/sortFunctions";
|
||||
import taxonomyFilter from "@/lib/utils/taxonomyFilter";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
@@ -27,13 +27,13 @@ export async function getStaticPaths() {
|
||||
tag,
|
||||
},
|
||||
}));
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
// Handle default path (no lang)
|
||||
const defaultCategories = await getTaxonomy(
|
||||
default_language as keyof ContentEntryMap,
|
||||
"tags",
|
||||
"tags"
|
||||
);
|
||||
const defaultPaths = defaultCategories.map((tag) => ({
|
||||
params: {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
---
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { slugSelector } from "@/lib/languageParser.astro";
|
||||
import { getAllTaxonomy, getTaxonomy } from "@/lib/taxonomyParser.astro";
|
||||
import { supportedLang } from "@/lib/utils/i18nUtils";
|
||||
import { slugSelector, supportedLang } from "@/lib/utils/languageParser";
|
||||
import { humanize } from "@/lib/utils/textConverter";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import type { ContentEntryMap } from "astro:content";
|
||||
|
||||
Reference in New Issue
Block a user