add title function so the builder is happy
This commit is contained in:
parent
9540cab4bb
commit
df6217cf34
2 changed files with 11 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: "[Rant] Social Media is tiring"
|
||||
title: "[Rant-ish] Social Media is tiring"
|
||||
date: [2023, 05, 27]
|
||||
# hidden: true
|
||||
---
|
||||
|
|
|
@ -11,15 +11,20 @@ import Link from "@/components/Link";
|
|||
import Image from "@/components/Image";
|
||||
import Head from "next/head";
|
||||
import matter from "gray-matter";
|
||||
import getFrontmatter from "@/lib/getFrontmatter";
|
||||
// import post from ""
|
||||
const Post = (props: { post: string, slug: string, matter: any }) => {
|
||||
|
||||
// console.log(props.matter)
|
||||
function title() {
|
||||
if(!props.matter) return `lio's blog`
|
||||
else return `${props.matter.title} | lio's blog`
|
||||
}
|
||||
|
||||
return (
|
||||
<RenderWithoutJS>
|
||||
<main id={index.layout}>
|
||||
<Head>
|
||||
<title>{props.matter.title} | lio's blog</title>
|
||||
<title>{title()}</title>
|
||||
</Head>
|
||||
<Sidebar />
|
||||
<section id={index.main}>
|
||||
|
@ -47,13 +52,11 @@ const Post = (props: { post: string, slug: string, matter: any }) => {
|
|||
export default Post
|
||||
|
||||
export async function getStaticProps(context: any) {
|
||||
let post = await remark()
|
||||
.use(remarkFrontmatter)
|
||||
.process(await read(`${listFiles('./src/blog').find(file => file.includes(context.params.slug))}`))
|
||||
let post = matter(await (await read(`${listFiles('./src/blog').find(file => file.includes(context.params.slug))}`)).value)
|
||||
return {
|
||||
props: {
|
||||
post: (post.value as string).replace(/^(---)\n*([a-zA-Z0-9\/\#[\]\"_:,\-\s*]*)(---)$/mi, ""),
|
||||
matter: matter(post.value).data,
|
||||
post: (post.content as string).replace(/^(---)\n*([a-zA-Z0-9\/\#[\]\"_:,\-\s*]*)(---)$/mi, ""),
|
||||
matter: post.data,
|
||||
slug: context.params.slug
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +66,6 @@ export async function getStaticProps(context: any) {
|
|||
export async function getStaticPaths() {
|
||||
let path = './src/blog'
|
||||
let paths = listFiles(path).map(file => file.replace(path, "/blog").replace(/.mdx?/gmi, ''))
|
||||
// console.log(paths)
|
||||
return {
|
||||
paths,
|
||||
fallback: true
|
||||
|
|
Loading…
Add table
Reference in a new issue