mirror of
https://github.com/10h30/astroplate.git
synced 2026-07-18 22:23:27 +09:00
tags pages added
This commit is contained in:
@@ -1,19 +1,25 @@
|
||||
---
|
||||
import BlogCard from "@/components/BlogCard.astro";
|
||||
import Share from "@/components/Share.astro";
|
||||
import config from "@/config/config.json";
|
||||
import Disqus from "@/helpers/Disqus";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import dateFormat from "@/lib/utils/dateFormat";
|
||||
import similarItems from "@/lib/utils/similarItems";
|
||||
import { humanize, markdownify, slugify } from "@/lib/utils/textConverter";
|
||||
import type { ContentEntryMap } from "astro:content";
|
||||
import { FaRegClock, FaRegFolder, FaRegUserCircle } from "react-icons/fa";
|
||||
import ImageMod from "./components/ImageMod.astro";
|
||||
const { default_language } = config.settings;
|
||||
|
||||
const COLLECTION_FOLDER = "blog";
|
||||
const { post } = Astro.props;
|
||||
const { lang } = Astro.params;
|
||||
|
||||
const posts = await getSinglePage(COLLECTION_FOLDER);
|
||||
const posts = await getSinglePage(
|
||||
COLLECTION_FOLDER,
|
||||
lang as keyof ContentEntryMap,
|
||||
);
|
||||
const similarPosts = similarItems(post, posts);
|
||||
const { Content } = await post.render();
|
||||
const { title, description, author, categories, image, date, tags } = post.data;
|
||||
@@ -40,7 +46,9 @@ const { title, description, author, categories, image, date, tags } = post.data;
|
||||
<h1 set:html={markdownify(title)} class="h2 mb-4" />
|
||||
<ul class="mb-4">
|
||||
<li class="mr-4 inline-block">
|
||||
<a href={`/${lang === "en" ? "authors" + "/" : lang}/authors/${slugify(author)}`} >
|
||||
<a
|
||||
href={`/${lang === default_language ? "authors" + "/" : lang}/authors/${slugify(author)}`}
|
||||
>
|
||||
<FaRegUserCircle className={"mr-2 -mt-1 inline-block"} />
|
||||
{humanize(author)}
|
||||
</a>
|
||||
@@ -50,7 +58,7 @@ const { title, description, author, categories, image, date, tags } = post.data;
|
||||
{
|
||||
categories.map((category: string, index: number) => (
|
||||
<a
|
||||
href={`/${lang === "en" ? "categories" + "/" : lang}/categories/${slugify(category)}`}
|
||||
href={`/${lang === default_language ? "categories" + "/" : lang}/categories/${slugify(category)}`}
|
||||
>
|
||||
{humanize(category)}
|
||||
{index !== categories.length - 1 && ","}
|
||||
|
||||
@@ -3,6 +3,8 @@ import { getLangFromUrl } from "@/lib/utils/i18nUtils";
|
||||
import { plainify } from "@/lib/utils/textConverter";
|
||||
import ImageMod from "./ImageMod.astro";
|
||||
import Social from "./Social.astro";
|
||||
import config from "@/config/config.json";
|
||||
const { default_language } = config.settings;
|
||||
|
||||
const { data } = Astro.props;
|
||||
const { title, image, social } = data.data;
|
||||
@@ -25,7 +27,8 @@ const lang = getLangFromUrl(Astro.url);
|
||||
)
|
||||
}
|
||||
<h4 class="mb-3">
|
||||
<a href={`/${lang === "en" ? "authors" + "/" : lang}/${data.slug}`}
|
||||
<a
|
||||
href={`/${lang === default_language ? "authors" + "/" : lang}/${data.slug}`}
|
||||
>{title}</a
|
||||
>
|
||||
</h4>
|
||||
|
||||
@@ -7,11 +7,9 @@ import type { ContentEntryMap } from "astro:content";
|
||||
import { FaRegFolder, FaRegUserCircle } from "react-icons/fa";
|
||||
import ImageMod from "./ImageMod.astro";
|
||||
|
||||
const {
|
||||
summary_length,
|
||||
blog_folder,
|
||||
}: { summary_length: number; blog_folder: string } = config.settings;
|
||||
const { defaultLang } = config.language;
|
||||
const { summary_length }: { summary_length: number; blog_folder: string } =
|
||||
config.settings;
|
||||
const { default_language } = config.settings;
|
||||
const { data } = Astro.props;
|
||||
const { title, image, date, author, categories } = data.data;
|
||||
|
||||
@@ -34,17 +32,15 @@ const { read_more } = await getTranslations(lang as keyof ContentEntryMap);
|
||||
)
|
||||
}
|
||||
<h4 class="mb-3">
|
||||
<a
|
||||
href={path.includes("/categories")
|
||||
? `${lang === defaultLang ? "" : `/${lang}`}/blog/${data.slug}`
|
||||
: `${lang === defaultLang ? "" : `/${lang}`}/${data.slug}`}
|
||||
>
|
||||
<a href={`${lang === default_language ? "" : `/${lang}`}/${data.slug}`}>
|
||||
{title}
|
||||
</a>
|
||||
</h4>
|
||||
<ul class="mb-4">
|
||||
<li class="mr-4 inline-block">
|
||||
<a href={`/${lang}/authors/${slugify(author)}`}>
|
||||
<a
|
||||
href={`${lang === default_language ? "" : `/${lang}`}/authors/${slugify(author)}`}
|
||||
>
|
||||
<FaRegUserCircle className={"mr-2 -mt-1 inline-block"} />
|
||||
{humanize(author)}
|
||||
</a>
|
||||
@@ -53,7 +49,9 @@ const { read_more } = await getTranslations(lang as keyof ContentEntryMap);
|
||||
<FaRegFolder className={"mr-2 -mt-1 inline-block"} />
|
||||
{
|
||||
categories.map((category: string, index: number) => (
|
||||
<a href={`/${lang}/categories/${slugify(category)}`}>
|
||||
<a
|
||||
href={`${lang === default_language ? "" : `/${lang}`}/categories/${slugify(category)}`}
|
||||
>
|
||||
{humanize(category)}
|
||||
{index !== categories.length - 1 && ","}
|
||||
</a>
|
||||
@@ -65,9 +63,7 @@ const { read_more } = await getTranslations(lang as keyof ContentEntryMap);
|
||||
<p class="mb-6">{plainify(data.body?.slice(0, Number(summary_length)))}</p>
|
||||
<a
|
||||
class="btn btn-outline-primary btn-sm"
|
||||
href={path.includes("/categories")
|
||||
? `${lang === defaultLang ? "" : `/${lang}`}/blog/${data.slug}`
|
||||
: `${lang === defaultLang ? "" : `/${lang}`}/${data.slug}`}
|
||||
href={`${lang === default_language ? "" : `/${lang}`}/${data.slug}`}
|
||||
>
|
||||
{read_more}
|
||||
</a>
|
||||
|
||||
@@ -1,32 +1,42 @@
|
||||
import config from "@/config/config.json";
|
||||
import languages from "@/config/language.json";
|
||||
import React from 'react';
|
||||
import React from "react";
|
||||
|
||||
const LanguageSwitcher = ({ lang, pathname }: { lang: string; pathname: string }) => {
|
||||
const LanguageSwitcher = ({
|
||||
lang,
|
||||
pathname,
|
||||
}: {
|
||||
lang: string;
|
||||
pathname: string;
|
||||
}) => {
|
||||
const { default_language } = config.settings;
|
||||
|
||||
return (
|
||||
<div className="mr-5">
|
||||
<select
|
||||
className="border border-dark py-1 rounded-sm"
|
||||
onChange={(e) => {
|
||||
const selectedLang = e.target.value;
|
||||
const newPath = selectedLang === "en"
|
||||
? pathname.replace(`/${lang}`, "")
|
||||
: `/${selectedLang}${pathname.replace(`/${lang}`, "")}`;
|
||||
window.location.href = newPath;
|
||||
}}
|
||||
value={lang}
|
||||
>
|
||||
{languages.map((language) => (
|
||||
<option
|
||||
key={language.languageCode}
|
||||
value={language.languageCode}
|
||||
>
|
||||
{language.languageName}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<div className="mr-5">
|
||||
<select
|
||||
className="border border-dark text-dark bg-transparent dark:border-darkmode-primary dark:text-white py-1 rounded-sm dark:bg cursor-pointer"
|
||||
onChange={(e) => {
|
||||
const selectedLang = e.target.value;
|
||||
const newPath =
|
||||
selectedLang === default_language
|
||||
? pathname.replace(`/${lang}`, "")
|
||||
: `/${selectedLang}${pathname.replace(`/${lang}`, "")}`;
|
||||
window.location.href = newPath;
|
||||
}}
|
||||
value={lang}
|
||||
>
|
||||
{languages.map((language) => (
|
||||
<option
|
||||
className="dark:text-dark"
|
||||
key={language.languageCode}
|
||||
value={language.languageCode}
|
||||
>
|
||||
{language.languageName}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default LanguageSwitcher;
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
import Logo from "@/components/Logo.astro";
|
||||
import Social from "@/components/Social.astro";
|
||||
import config from "@/config/config.json";
|
||||
import menu from "@/config/menu.json";
|
||||
import social from "@/config/social.json";
|
||||
import { getLangFromUrl } from "@/lib/utils/i18nUtils";
|
||||
import { loadMenu } from "@/lib/utils/loadMenu";
|
||||
import { markdownify } from "@/lib/utils/textConverter";
|
||||
|
||||
const lang = getLangFromUrl(Astro.url);
|
||||
const menu = loadMenu(lang);
|
||||
const { footer }: { footer: { name: string; url: string }[] } = menu;
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user