mirror of
https://github.com/10h30/astroplate.git
synced 2026-07-18 14:13:30 +09:00
disabled ln fn added
This commit is contained in:
+17
-3
@@ -2,11 +2,13 @@
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import {
|
||||
constructUrl,
|
||||
getLangFromUrl,
|
||||
getTranslations,
|
||||
supportedLang,
|
||||
} from "@/lib/utils/i18nUtils";
|
||||
import type { ContentEntryMap } from "astro:content";
|
||||
const { trailing_slash } = config.site;
|
||||
|
||||
export function getStaticPaths() {
|
||||
const paths = supportedLang.map((lang) => ({
|
||||
@@ -15,11 +17,23 @@ export function getStaticPaths() {
|
||||
return paths;
|
||||
}
|
||||
|
||||
const lang = getLangFromUrl(Astro.url);
|
||||
let lang = getLangFromUrl(Astro.url);
|
||||
|
||||
// Check if the current language is disabled
|
||||
const disabledLanguages = config.settings.disable_languages as string[];
|
||||
if (disabledLanguages.includes(lang)) {
|
||||
// Redirect to the default language or handle as per your application logic
|
||||
lang = config.settings.default_language;
|
||||
}
|
||||
|
||||
const { page_not_found_content, page_not_found, back_to_home } =
|
||||
await getTranslations(lang as keyof ContentEntryMap);
|
||||
const { default_language } = config.settings;
|
||||
const href = lang && lang !== default_language ? `/${lang}/` : "/";
|
||||
const href = constructUrl(
|
||||
"/",
|
||||
lang,
|
||||
config.settings.default_language,
|
||||
trailing_slash
|
||||
);
|
||||
---
|
||||
|
||||
<Base title="Page Not Found">
|
||||
|
||||
@@ -4,6 +4,7 @@ import Base from "@/layouts/Base.astro";
|
||||
import { getListPage } from "@/lib/contentParser.astro";
|
||||
import { getTranslations, supportedLang } from "@/lib/utils/i18nUtils";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import type { CollectionKey } from "astro:content";
|
||||
import { type ContentEntryMap } from "astro:content";
|
||||
|
||||
export function getStaticPaths() {
|
||||
@@ -14,7 +15,10 @@ export function getStaticPaths() {
|
||||
}
|
||||
|
||||
const { lang } = Astro.params;
|
||||
const contact = await getListPage("contact", lang as keyof ContentEntryMap);
|
||||
const contact: any = await getListPage(
|
||||
"contact" as CollectionKey,
|
||||
lang as keyof ContentEntryMap
|
||||
);
|
||||
|
||||
const { contact_form_action }: { contact_form_action: string } = config.params;
|
||||
const { title, description, meta_title, image } = contact[0].data;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
---
|
||||
import ImageMod from "@/components/ImageMod.astro";
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getListPage, getSinglePage } from "@/lib/contentParser.astro";
|
||||
import { supportedLang } from "@/lib/utils/i18nUtils";
|
||||
@@ -10,8 +9,6 @@ import Testimonial from "@/partials/Testimonial.astro";
|
||||
import type { Button, Feature } from "@/types";
|
||||
import type { ContentCollectionKey, ContentEntryMap } from "astro:content";
|
||||
import { FaCheck } from "react-icons/fa";
|
||||
const { default_language } = config.settings;
|
||||
|
||||
interface Homepage {
|
||||
banner: {
|
||||
title: string;
|
||||
@@ -32,18 +29,18 @@ export function getStaticPaths() {
|
||||
const { lang } = Astro.params;
|
||||
const homepage: any = await getListPage(
|
||||
"homepage" as ContentCollectionKey,
|
||||
lang as keyof ContentEntryMap,
|
||||
lang as keyof ContentEntryMap
|
||||
);
|
||||
const { banner, features } = homepage[0].data;
|
||||
const { banner, features }: Homepage = homepage[0].data;
|
||||
|
||||
const testimonial = await getSinglePage(
|
||||
"sections/testimonial" as ContentCollectionKey,
|
||||
lang as keyof ContentEntryMap,
|
||||
lang as keyof ContentEntryMap
|
||||
);
|
||||
|
||||
const call_to_action = await getSinglePage(
|
||||
"sections/call-to-action" as ContentCollectionKey,
|
||||
lang as keyof ContentEntryMap,
|
||||
lang as keyof ContentEntryMap
|
||||
);
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user