mirror of
https://github.com/10h30/astroplate.git
synced 2026-07-11 18:56:06 +09:00
readme modified
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
"blog_folder": "blog",
|
||||
"default_language": "en",
|
||||
"disable_languages": [],
|
||||
"default_language_in_path": false
|
||||
"default_language_in_subdir": true
|
||||
},
|
||||
|
||||
"params": {
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
import { defineCollection, z } from "astro:content";
|
||||
|
||||
const elementsCollection = defineCollection({
|
||||
schema: z.object({
|
||||
title: z.string(),
|
||||
meta_title: z.string().optional(),
|
||||
description: z.string(),
|
||||
draft: z.boolean().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
const privacyCollection = defineCollection({
|
||||
schema: z.object({
|
||||
title: z.string(),
|
||||
meta_title: z.string().optional(),
|
||||
description: z.string(),
|
||||
draft: z.boolean().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
export const collections = {
|
||||
elements: elementsCollection,
|
||||
privacy: privacyCollection,
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import config from "@/config/config.json";
|
||||
import languages from "@/config/language.json";
|
||||
import languages from "@/config/language.json"; ``
|
||||
import React from "react";
|
||||
|
||||
const LanguageSwitcher = ({
|
||||
@@ -21,11 +21,12 @@ const LanguageSwitcher = ({
|
||||
|
||||
// Sort languages by weight and filter out disabled languages
|
||||
const sortedLanguages = languages
|
||||
// @ts-ignore
|
||||
.filter(language => !config.settings.disable_languages.includes(language.languageCode))
|
||||
.sort((a, b) => a.weight - b.weight);
|
||||
|
||||
return (
|
||||
<div className="mr-5">
|
||||
<div className={`mr-5 ${sortedLanguages.length > 1 ? "block" : "hidden"}`}>
|
||||
<select
|
||||
className="border border-dark text-dark bg-transparent dark:border-darkmode-primary dark:text-white py-1 rounded-sm cursor-pointer focus:ring-0 focus:border-dark dark:focus:border-darkmode-primary"
|
||||
onChange={(e) => {
|
||||
@@ -55,4 +56,4 @@ const LanguageSwitcher = ({
|
||||
);
|
||||
};
|
||||
|
||||
export default LanguageSwitcher;
|
||||
export default LanguageSwitcher;
|
||||
|
||||
@@ -4,7 +4,11 @@ import ThemeSwitcher from "@/components/ThemeSwitcher.astro";
|
||||
import config from "@/config/config.json";
|
||||
import languages from "@/config/language.json";
|
||||
import LanguageSwitcher from "@/helpers/LanguageSwitcher";
|
||||
import { getLangFromUrl, getTranslations, slugSelector } from "@/lib/utils/languageParser";
|
||||
import {
|
||||
getLangFromUrl,
|
||||
getTranslations,
|
||||
slugSelector,
|
||||
} from "@/lib/utils/languageParser";
|
||||
import type { ContentEntryMap } from "astro:content";
|
||||
import { IoSearch } from "react-icons/io5";
|
||||
|
||||
@@ -133,12 +137,10 @@ if (disabledLanguages.includes(lang)) {
|
||||
}
|
||||
{/* Theme switcher */}
|
||||
<ThemeSwitcher className="mr-5" />
|
||||
|
||||
{/* Language switcher */}
|
||||
{
|
||||
languages.length > 1 && (
|
||||
<LanguageSwitcher client:load lang={lang} pathname={pathname} />
|
||||
)
|
||||
}
|
||||
<LanguageSwitcher client:load lang={lang} pathname={pathname} />
|
||||
|
||||
{/* Navigation button */}
|
||||
{
|
||||
navigation_button.enable && (
|
||||
|
||||
@@ -76,7 +76,7 @@ const filteredSupportedLang = supportedLang.filter(
|
||||
export { filteredSupportedLang as supportedLang };
|
||||
|
||||
export const slugSelector = (url: string, lang: string) => {
|
||||
const { default_language, default_language_in_path } = config.settings;
|
||||
const { default_language, default_language_in_subdir } = config.settings;
|
||||
const { trailing_slash } = config.site;
|
||||
|
||||
let constructedUrl;
|
||||
@@ -108,7 +108,7 @@ export const slugSelector = (url: string, lang: string) => {
|
||||
|
||||
// Add language path if necessary
|
||||
if (lang === default_language) {
|
||||
constructedUrl = default_language_in_path
|
||||
constructedUrl = default_language_in_subdir
|
||||
? `/${lang}${constructedUrl}`
|
||||
: constructedUrl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user