feat: add research submodule and page
This commit is contained in:
parent
4a39e535a3
commit
3af3260500
12 changed files with 68 additions and 48 deletions
|
|
@ -5,30 +5,30 @@ import { getDoc, getDocs } from '@utils'
|
|||
import styles from './page.module.css'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'chora blog | news',
|
||||
title: 'chora studio | research',
|
||||
}
|
||||
|
||||
export const generateStaticParams = () => {
|
||||
return getDocs()
|
||||
}
|
||||
|
||||
const PostPage = async ({ params }: any) => {
|
||||
const post = await getDoc(params.id)
|
||||
const DocumentPage = async ({ params }: any) => {
|
||||
const doc = await getDoc(params.id)
|
||||
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
<div className={styles.banner}>
|
||||
<div>
|
||||
<h3>{post.date}</h3>
|
||||
<h1>{post.title}</h1>
|
||||
<h2>{`by ${post.author}`}</h2>
|
||||
<h3>{doc.date}</h3>
|
||||
<h1>{doc.title}</h1>
|
||||
<h2>{`by ${doc.author}`}</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.content}>
|
||||
<div dangerouslySetInnerHTML={{ __html: post.content }} />
|
||||
<div dangerouslySetInnerHTML={{ __html: doc.content }} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default PostPage
|
||||
export default DocumentPage
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ import { getDocs } from '@utils'
|
|||
import styles from './page.module.css'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'chora blog | research',
|
||||
title: 'chora studio | research',
|
||||
}
|
||||
|
||||
async function getPosts() {
|
||||
const allPosts = getDocs().filter((p) => p.tags.includes('research'))
|
||||
async function getResearch() {
|
||||
const allDocs = getDocs().filter((p) => p.tags.includes('research'))
|
||||
|
||||
// sort posts by date
|
||||
return allPosts.sort((a, b) => {
|
||||
// sort docs by date
|
||||
return allDocs.sort((a, b) => {
|
||||
if (a.date < b.date) {
|
||||
return 1
|
||||
} else {
|
||||
|
|
@ -23,7 +23,7 @@ async function getPosts() {
|
|||
}
|
||||
|
||||
const ResearchPage = async () => {
|
||||
const posts = await getPosts()
|
||||
const docs = await getResearch()
|
||||
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
|
|
@ -33,11 +33,11 @@ const ResearchPage = async () => {
|
|||
</div>
|
||||
</div>
|
||||
<div className={styles.content}>
|
||||
{!posts.length ? (
|
||||
{!docs.length ? (
|
||||
<p>{'coming soon...'}</p>
|
||||
) : (
|
||||
<ul>
|
||||
{posts.map(({ id, date, title, author }) => (
|
||||
{docs.map(({ id, date, title, author }) => (
|
||||
<li key={id}>
|
||||
<Link href={`/research/${id}`}>
|
||||
<h4>{date}</h4>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue