mirror of
https://github.com/10h30/astroplate.git
synced 2026-07-11 18:56:06 +09:00
127 lines
4.0 KiB
Plaintext
Executable File
127 lines
4.0 KiB
Plaintext
Executable File
---
|
|
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 { slugSelector } from "@/lib/languageParser.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;
|
|
let { lang } = Astro.params;
|
|
|
|
if (!lang) {
|
|
lang = default_language;
|
|
}
|
|
|
|
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;
|
|
---
|
|
|
|
<section class="section pt-7">
|
|
<div class="container">
|
|
<div class="row justify-center">
|
|
<article class="lg:col-10">
|
|
{
|
|
image && (
|
|
<div class="mb-10">
|
|
<ImageMod
|
|
src={image}
|
|
height={500}
|
|
width={1200}
|
|
alt={title}
|
|
class="w-full rounded"
|
|
format="webp"
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
<h1 set:html={markdownify(title)} class="h2 mb-4" />
|
|
<ul class="mb-4">
|
|
<li class="mr-4 inline-block">
|
|
<a href={slugSelector(`/authors/${slugify(author)}`, lang)}>
|
|
<FaRegUserCircle className={"mr-2 -mt-1 inline-block"} />
|
|
{humanize(author)}
|
|
</a>
|
|
</li>
|
|
<li class="mr-4 inline-block">
|
|
<FaRegFolder className={"mr-2 -mt-1 inline-block"} />
|
|
{
|
|
categories.map((category: string, index: number) => (
|
|
<a
|
|
href={slugSelector(`/categories/${slugify(category)}`, lang)}
|
|
>
|
|
{humanize(category)}
|
|
{index !== categories.length - 1 && ","}
|
|
</a>
|
|
))
|
|
}
|
|
</li>
|
|
<li class="mr-4 inline-block">
|
|
<FaRegClock className={"mr-2 -mt-1 inline-block"} />
|
|
{dateFormat(date)}
|
|
</li>
|
|
</ul>
|
|
<div class="content mb-10">
|
|
<Content />
|
|
</div>
|
|
<div class="row items-start justify-between">
|
|
<div class="mb-10 flex items-center lg:col-5 lg:mb-0">
|
|
<h5 class="mr-3">Tags :</h5>
|
|
<ul>
|
|
{
|
|
tags.map((tag: string) => (
|
|
<li class="inline-block">
|
|
<a
|
|
class="m-1 block rounded bg-theme-light px-3 py-1 hover:bg-primary hover:text-white dark:bg-darkmode-theme-light dark:hover:bg-darkmode-primary dark:hover:text-dark"
|
|
href={slugSelector(`/tags/${slugify(tag)}`, lang)}
|
|
>
|
|
{humanize(tag)}
|
|
</a>
|
|
</li>
|
|
))
|
|
}
|
|
</ul>
|
|
</div>
|
|
<div class="flex items-center lg:col-4">
|
|
<h5 class="mr-3">Share :</h5>
|
|
<Share
|
|
className="social-icons"
|
|
title={title}
|
|
description={description}
|
|
slug={post.slug}
|
|
/>
|
|
</div>
|
|
</div>
|
|
<Disqus className="mt-20" client:load />
|
|
</article>
|
|
</div>
|
|
|
|
<!-- Related posts -->
|
|
<div class="section pb-0">
|
|
<h2 class="h3 mb-12 text-center">Related Posts</h2>
|
|
<div class="row justify-center">
|
|
{
|
|
similarPosts.map((post) => (
|
|
<div class="lg:col-4 md:col-6 mb-14">
|
|
<BlogCard data={post} />
|
|
</div>
|
|
))
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|