config ln array changed

This commit is contained in:
Al Murad Uzzaman
2024-05-16 17:11:25 +06:00
parent 97d6f22dcb
commit c137b8afcd
24 changed files with 200 additions and 362 deletions
+9 -6
View File
@@ -1,20 +1,23 @@
---
import config from "@/config/config.json";
import dateFormat from "@/lib/utils/dateFormat";
import { getLangFromUrl, getTranslations } from "@/lib/utils/i18nUtils";
import { humanize, plainify, slugify } from "@/lib/utils/textConverter";
import type { ContentEntryMap } from "astro:content";
import { FaRegFolder, FaRegUserCircle } from "react-icons/fa";
import ImageMod from "./ImageMod.astro";
import { getLangFromUrl } from "@/lib/utils/i18nUtils";
const {
summary_length,
blog_folder,
}: { summary_length: number; blog_folder: string } = config.settings;
const { defaultLang } = config.language;
const { data } = Astro.props;
const { title, image, date, author, categories } = data.data;
const lang = getLangFromUrl(Astro.url);
const path = Astro.url.pathname;
const { read_more } = await getTranslations(lang as keyof ContentEntryMap);
---
<div class="bg-body dark:bg-darkmode-body">
@@ -33,8 +36,8 @@ const path = Astro.url.pathname;
<h4 class="mb-3">
<a
href={path.includes("/categories")
? `/${lang === "en" ? "/" : lang}/blog/${data.slug}`
: `/${lang === "en" ? "/" : lang}/${data.slug}`}
? `${lang === defaultLang ? "" : `/${lang}`}/blog/${data.slug}`
: `${lang === defaultLang ? "" : `/${lang}`}/${data.slug}`}
>
{title}
</a>
@@ -63,9 +66,9 @@ const path = Astro.url.pathname;
<a
class="btn btn-outline-primary btn-sm"
href={path.includes("/categories")
? `/${lang === "en" ? "/" : lang}/blog/${data.slug}`
: `/${lang === "en" ? "/" : lang}/${data.slug}`}
? `${lang === defaultLang ? "" : `/${lang}`}/blog/${data.slug}`
: `${lang === defaultLang ? "" : `/${lang}`}/${data.slug}`}
>
read more
{read_more}
</a>
</div>
+6 -6
View File
@@ -1,15 +1,13 @@
---
import { supportedLang } from "@/lib/utils/i18nUtils";
import { humanize } from "@/lib/utils/textConverter";
import config from "@/config/config.json";
const { supported } = config.language;
const { className }: { className?: string } = Astro.props;
const paths = Astro.url.pathname.split("/").filter((x) => x);
let lang = "";
if (supported.includes(paths[0])) {
if (supportedLang.includes(paths[0])) {
lang = paths.shift()!;
}
@@ -17,7 +15,10 @@ let parts = [
{
label: "Home",
href: `/${lang}`,
"aria-label": Astro.url.pathname === `/${lang}` || Astro.url.pathname === `/${lang}/` ? "page" : undefined,
"aria-label":
Astro.url.pathname === `/${lang}` || Astro.url.pathname === `/${lang}/`
? "page"
: undefined,
},
];
@@ -30,7 +31,6 @@ paths.forEach((label: string, i: number) => {
"aria-label": Astro.url.pathname === href ? "page" : undefined,
});
});
---
<nav aria-label="Breadcrumb" class={className}>
+9 -8
View File
@@ -1,6 +1,8 @@
import languages from "@/config/language.json";
import React from 'react';
const LanguageSwitcher = ({ lang, languages, pathname }: { lang: string; languages: string[]; pathname: string }) => {
const LanguageSwitcher = ({ lang, pathname }: { lang: string; pathname: string }) => {
return (
<div className="mr-5">
<select
@@ -12,20 +14,19 @@ const LanguageSwitcher = ({ lang, languages, pathname }: { lang: string; languag
: `/${selectedLang}${pathname.replace(`/${lang}`, "")}`;
window.location.href = newPath;
}}
value={languages.includes(lang) ? lang : 'en'}
value={lang}
>
{languages.map((child: string) => (
{languages.map((language) => (
<option
key={child}
value={child}
key={language.languageCode}
value={language.languageCode}
>
{child}
{language.languageName}
</option>
))}
</select>
</div>
)
}
export default LanguageSwitcher
export default LanguageSwitcher;
+7 -15
View File
@@ -3,21 +3,18 @@ import Logo from "@/components/Logo.astro";
import ThemeSwitcher from "@/components/ThemeSwitcher.astro";
import config from "@/config/config.json";
import LanguageSwitcher from "@/helpers/LanguageSwitcher";
import {
getLangFromUrl,
languages,
useTranslations,
} from "@/lib/utils/i18nUtils";
import { getLangFromUrl, getTranslations } from "@/lib/utils/i18nUtils";
import { loadMenu } from "@/lib/utils/loadMenu";
import type { ContentEntryMap } from "astro:content";
import { getRelativeLocaleUrl } from "astro:i18n";
import { IoSearch } from "react-icons/io5";
const lang = getLangFromUrl(Astro.url);
const menu = loadMenu(lang);
const { navigation_button, settings } = config;
const { pathname } = Astro.url;
const t = useTranslations(lang as any);
const { get_started } = await getTranslations(lang as keyof ContentEntryMap);
---
<header class={`header z-30 ${settings.sticky_header && "sticky top-0"}`}>
@@ -113,7 +110,7 @@ const t = useTranslations(lang as any);
class="btn btn-outline-primary btn-sm"
href={navigation_button.link}
>
{t("get_started")}
{get_started}
</a>
</li>
)
@@ -133,19 +130,14 @@ const t = useTranslations(lang as any);
)
}
<ThemeSwitcher className="mr-5" />
<LanguageSwitcher
client:load
lang={lang}
languages={languages}
pathname={pathname}
/>
<LanguageSwitcher client:load lang={lang} pathname={pathname} />
{
navigation_button.enable && (
<a
class="btn btn-outline-primary btn-sm hidden lg:inline-block"
href={navigation_button.link}
>
{t("get_started")}
{get_started}
</a>
)
}