mirror of
https://github.com/10h30/astroplate.git
synced 2026-07-18 06:03:27 +09:00
tags pages added
This commit is contained in:
+7
-4
@@ -1,9 +1,12 @@
|
||||
---
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getLangFromUrl, getTranslations } from "@/lib/utils/i18nUtils";
|
||||
import {
|
||||
getLangFromUrl,
|
||||
getTranslations,
|
||||
supportedLang,
|
||||
} from "@/lib/utils/i18nUtils";
|
||||
import type { ContentEntryMap } from "astro:content";
|
||||
import { supportedLang } from "@/lib/utils/i18nUtils";
|
||||
|
||||
export function getStaticPaths() {
|
||||
const paths = supportedLang.map((lang) => ({
|
||||
@@ -15,8 +18,8 @@ export function getStaticPaths() {
|
||||
const lang = getLangFromUrl(Astro.url);
|
||||
const { page_not_found_content, page_not_found, back_to_home } =
|
||||
await getTranslations(lang as keyof ContentEntryMap);
|
||||
const { defaultLang } = config.language;
|
||||
const href = lang && lang !== defaultLang ? `/${lang}/` : "/";
|
||||
const { default_language } = config.settings;
|
||||
const href = lang && lang !== default_language ? `/${lang}/` : "/";
|
||||
---
|
||||
|
||||
<Base title="Page Not Found">
|
||||
|
||||
@@ -4,6 +4,8 @@ import Base from "@/layouts/Base.astro";
|
||||
import { getListPage } from "@/lib/contentParser.astro";
|
||||
import { supportedLang } from "@/lib/utils/i18nUtils";
|
||||
import { markdownify } from "@/lib/utils/textConverter";
|
||||
import type { ContentEntryMap } from "astro:content";
|
||||
import type { ContentCollectionKey } from "astro:content";
|
||||
|
||||
export function getStaticPaths() {
|
||||
const paths = supportedLang.map((lang) => ({
|
||||
@@ -13,7 +15,10 @@ export function getStaticPaths() {
|
||||
}
|
||||
|
||||
const { lang } = Astro.params;
|
||||
const about = await getListPage("about", lang);
|
||||
const about: any = await getListPage(
|
||||
"about" as ContentCollectionKey,
|
||||
lang as keyof ContentEntryMap,
|
||||
);
|
||||
|
||||
const { Content } = await about[0].render();
|
||||
const { title, description, meta_title, image } = about[0].data;
|
||||
|
||||
@@ -7,6 +7,7 @@ import { supportedLang } from "@/lib/utils/i18nUtils";
|
||||
import { sortByDate } from "@/lib/utils/sortFunctions";
|
||||
import taxonomyFilter from "@/lib/utils/taxonomyFilter";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import type { ContentEntryMap } from "astro:content";
|
||||
|
||||
// get all static paths for categories
|
||||
export async function getStaticPaths() {
|
||||
@@ -23,7 +24,7 @@ export async function getStaticPaths() {
|
||||
category,
|
||||
},
|
||||
}));
|
||||
})
|
||||
}),
|
||||
);
|
||||
return paths.flat();
|
||||
}
|
||||
@@ -32,7 +33,7 @@ const { category, lang } = Astro.params;
|
||||
|
||||
// get posts by category
|
||||
const BLOG_FOLDER = "blog";
|
||||
const posts = await getSinglePage(BLOG_FOLDER, lang as any);
|
||||
const posts = await getSinglePage(BLOG_FOLDER, lang as keyof ContentEntryMap);
|
||||
const filterByCategories = taxonomyFilter(posts, "categories", category!);
|
||||
const sortedPosts = sortByDate(filterByCategories);
|
||||
---
|
||||
|
||||
@@ -30,7 +30,7 @@ const allCategories = await getAllTaxonomy(langCollection, "categories");
|
||||
return (
|
||||
<li class="m-3 inline-block">
|
||||
<a
|
||||
href={`/${lang === "en" ? "categories" + "/" : lang}/categories/${category}`}
|
||||
href={`/${lang === "" ? "categories" + "/" : lang}/categories/${category}`}
|
||||
class="block rounded bg-theme-light px-4 py-2 text-xl text-dark dark:bg-darkmode-theme-light dark:text-darkmode-dark"
|
||||
>
|
||||
{humanize(category)}{" "}
|
||||
|
||||
@@ -3,15 +3,15 @@ import ImageMod from "@/components/ImageMod.astro";
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getListPage } from "@/lib/contentParser.astro";
|
||||
import { supportedLang } from "@/lib/utils/i18nUtils";
|
||||
import { markdownify } from "@/lib/utils/textConverter";
|
||||
import CallToAction from "@/partials/CallToAction.astro";
|
||||
import Testimonial from "@/partials/Testimonial.astro";
|
||||
import type { Button, Feature } from "@/types";
|
||||
import type { ContentEntryMap } from "astro:content";
|
||||
import type { ContentCollectionKey, ContentEntryMap } from "astro:content";
|
||||
import { getCollection } from "astro:content";
|
||||
import { FaCheck } from "react-icons/fa";
|
||||
const { defaultLang } = config.language;
|
||||
import { supportedLang } from "@/lib/utils/i18nUtils";
|
||||
const { default_language } = config.settings;
|
||||
|
||||
interface Homepage {
|
||||
banner: {
|
||||
@@ -31,22 +31,25 @@ export function getStaticPaths() {
|
||||
}
|
||||
|
||||
const { lang } = Astro.params;
|
||||
const homepage = await getListPage("homepage", lang);
|
||||
const { banner, features }: Homepage = homepage[0].data;
|
||||
const homepage: any = await getListPage(
|
||||
"homepage" as ContentCollectionKey,
|
||||
lang as keyof ContentEntryMap,
|
||||
);
|
||||
const { banner, features } = homepage[0].data;
|
||||
|
||||
const testimonial = await getCollection(
|
||||
(lang as keyof ContentEntryMap) || defaultLang,
|
||||
(lang as keyof ContentEntryMap) || default_language,
|
||||
({ id }: any) => {
|
||||
return id.startsWith("sections/testimonial") && !id.endsWith("-index.md");
|
||||
}
|
||||
},
|
||||
);
|
||||
const call_to_action = await getCollection(
|
||||
(lang as keyof ContentEntryMap) || defaultLang,
|
||||
(lang as keyof ContentEntryMap) || default_language,
|
||||
({ id }: any) => {
|
||||
return (
|
||||
id.startsWith("sections/call-to-action") && !id.endsWith("-index.md")
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
---
|
||||
|
||||
@@ -96,7 +99,7 @@ const call_to_action = await getCollection(
|
||||
|
||||
<!-- Features -->
|
||||
{
|
||||
features.map((feature, index: number) => (
|
||||
features.map((feature: Feature, index: number) => (
|
||||
<section class={`section-sm ${index % 2 === 0 && "bg-gradient"}`}>
|
||||
<div class="container">
|
||||
<div class="row items-center justify-between">
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
---
|
||||
import BlogCard from "@/components/BlogCard.astro";
|
||||
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 { sortByDate } from "@/lib/utils/sortFunctions";
|
||||
import taxonomyFilter from "@/lib/utils/taxonomyFilter";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import type { ContentEntryMap } from "astro:content";
|
||||
|
||||
// get all static paths for categories
|
||||
export async function getStaticPaths() {
|
||||
const paths = await Promise.all(
|
||||
supportedLang.map(async (lang) => {
|
||||
const tags = await getTaxonomy(lang, "tags");
|
||||
|
||||
return tags.map((tag) => ({
|
||||
params: {
|
||||
lang: lang || undefined,
|
||||
tag: tag,
|
||||
},
|
||||
props: {
|
||||
tag,
|
||||
},
|
||||
}));
|
||||
}),
|
||||
);
|
||||
return paths.flat();
|
||||
}
|
||||
|
||||
const { tag, lang } = Astro.params;
|
||||
|
||||
// get posts by tag
|
||||
const BLOG_FOLDER = "blog";
|
||||
const posts = await getSinglePage(BLOG_FOLDER, lang as keyof ContentEntryMap);
|
||||
const filterByTags = taxonomyFilter(posts, "tags", tag!);
|
||||
const sortedPosts = sortByDate(filterByTags);
|
||||
---
|
||||
|
||||
<Base title={tag}>
|
||||
<PageHeader title={tag} />
|
||||
<div class="section-sm pb-0">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
{
|
||||
sortedPosts.map((post) => (
|
||||
<div class="mb-14 md:col-6 lg:col-4">
|
||||
<BlogCard data={post} />
|
||||
</div>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Base>
|
||||
@@ -0,0 +1,48 @@
|
||||
---
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getAllTaxonomy, getTaxonomy } from "@/lib/taxonomyParser.astro";
|
||||
import { supportedLang } from "@/lib/utils/i18nUtils";
|
||||
import { humanize } from "@/lib/utils/textConverter";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import type { ContentEntryMap } from "astro:content";
|
||||
|
||||
export function getStaticPaths() {
|
||||
const paths = supportedLang.map((lang) => ({
|
||||
params: { lang: lang || undefined },
|
||||
}));
|
||||
return paths;
|
||||
}
|
||||
|
||||
const { lang } = Astro.params;
|
||||
const langCollection: keyof ContentEntryMap = lang as keyof ContentEntryMap;
|
||||
const tags = await getTaxonomy(langCollection, "tags");
|
||||
const allTags = await getAllTaxonomy(langCollection, "tags");
|
||||
---
|
||||
|
||||
<Base title={"Tags"}>
|
||||
<PageHeader title={"Tags"} />
|
||||
<section class="section">
|
||||
<div class="container text-center">
|
||||
<ul>
|
||||
{
|
||||
tags.map((tag: any) => {
|
||||
const count = allTags.filter((c) => c === tag).length;
|
||||
return (
|
||||
<li class="m-3 inline-block">
|
||||
<a
|
||||
href={`/${lang === "" ? "tags" + "/" : lang}/tags/${tag}`}
|
||||
class="block rounded bg-theme-light px-4 py-2 text-xl text-dark dark:bg-darkmode-theme-light dark:text-darkmode-dark"
|
||||
>
|
||||
{humanize(tag)}{" "}
|
||||
<span class="ml-2 rounded bg-body px-2 dark:bg-darkmode-body">
|
||||
{count}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
);
|
||||
})
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</Base>
|
||||
Reference in New Issue
Block a user