Fix blog tables (remark-gfm), update portfolio images, fix dropdown hover issues, remove contact form

This commit is contained in:
Kunthawat Greethong
2026-02-26 21:44:02 +07:00
parent f54c020097
commit dccfce8186
14 changed files with 196 additions and 203 deletions

View File

@@ -6,9 +6,9 @@ import path from 'path';
import matter from 'gray-matter';
import { remark } from 'remark';
import html from 'remark-html';
import gfm from 'remark-gfm';
interface Props {
params: { slug: string };
params: Promise<{ slug: string }>;
}
async function getPost(slug: string) {
@@ -23,24 +23,32 @@ async function getPost(slug: string) {
const { data, content } = matter(fileContent);
const processedContent = await remark()
.use(gfm)
.use(html, { sanitize: false })
.process(content);
const contentHtml = processedContent.toString();
// Support both 'category' and 'categories' field names
const category = data.category || (Array.isArray(data.categories) ? data.categories[0] : 'ทั่วไป');
// Support both 'image' and 'featuredImage' field names
const image = data.image || data.featuredImage || '/images/2021/03/ppr-pipe_000C.jpg';
return {
slug,
title: data.title || 'ไม่มีชื่อ',
excerpt: data.excerpt || '',
date: data.date || new Date().toISOString(),
author: data.author || 'ดีลพลัสเทค',
category: data.category || 'ทั่วไป',
image: data.image || '/images/2021/03/ppr-pipe_000C.jpg',
category,
image,
content: contentHtml,
};
}
export async function generateMetadata({ params }: Props) {
const post = await getPost(params.slug);
const { slug } = await params;
const decodedSlug = decodeURIComponent(slug);
const post = await getPost(decodedSlug);
if (!post) return { title: 'ไม่พบบทความ' };
return {
@@ -59,7 +67,9 @@ export async function generateStaticParams() {
}
export default async function BlogPostPage({ params }: Props) {
const post = await getPost(params.slug);
const { slug } = await params;
const decodedSlug = decodeURIComponent(slug);
const post = await getPost(decodedSlug);
if (!post) {
notFound();