feat: add research submodule and page
This commit is contained in:
parent
3d450a389b
commit
4a39e535a3
13 changed files with 217 additions and 10 deletions
11
app/research/[id]/page.module.css
Normal file
11
app/research/[id]/page.module.css
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
.page {
|
||||
composes: page from 'chora/styles/page.css';
|
||||
}
|
||||
|
||||
.banner {
|
||||
composes: banner-document from 'chora/styles/main.css';
|
||||
}
|
||||
|
||||
.content {
|
||||
composes: content-full from 'chora/styles/main.css';
|
||||
}
|
||||
34
app/research/[id]/page.tsx
Normal file
34
app/research/[id]/page.tsx
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { Metadata } from 'next'
|
||||
|
||||
import { getDoc, getDocs } from '@utils'
|
||||
|
||||
import styles from './page.module.css'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'chora blog | news',
|
||||
}
|
||||
|
||||
export const generateStaticParams = () => {
|
||||
return getDocs()
|
||||
}
|
||||
|
||||
const PostPage = async ({ params }: any) => {
|
||||
const post = 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>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.content}>
|
||||
<div dangerouslySetInnerHTML={{ __html: post.content }} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default PostPage
|
||||
27
app/research/page.module.css
Normal file
27
app/research/page.module.css
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
.page {
|
||||
composes: page from 'chora/styles/page.css';
|
||||
}
|
||||
|
||||
.banner {
|
||||
composes: banner from 'chora/styles/main.css';
|
||||
}
|
||||
|
||||
.content {
|
||||
composes: content-full from 'chora/styles/main.css';
|
||||
}
|
||||
|
||||
.content h2 {
|
||||
margin: 0.5em 0;
|
||||
}
|
||||
|
||||
.content h3 {
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.content h4 {
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.content ul {
|
||||
list-style: none inside none;
|
||||
}
|
||||
56
app/research/page.tsx
Normal file
56
app/research/page.tsx
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
import { Metadata } from 'next'
|
||||
import Link from 'next/link'
|
||||
|
||||
import { getDocs } from '@utils'
|
||||
|
||||
import styles from './page.module.css'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'chora blog | research',
|
||||
}
|
||||
|
||||
async function getPosts() {
|
||||
const allPosts = getDocs().filter((p) => p.tags.includes('research'))
|
||||
|
||||
// sort posts by date
|
||||
return allPosts.sort((a, b) => {
|
||||
if (a.date < b.date) {
|
||||
return 1
|
||||
} else {
|
||||
return -1
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const ResearchPage = async () => {
|
||||
const posts = await getPosts()
|
||||
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
<div className={styles.banner}>
|
||||
<div>
|
||||
<h1 style={{ opacity: '0.75' }}>{'research'}</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.content}>
|
||||
{!posts.length ? (
|
||||
<p>{'coming soon...'}</p>
|
||||
) : (
|
||||
<ul>
|
||||
{posts.map(({ id, date, title, author }) => (
|
||||
<li key={id}>
|
||||
<Link href={`/research/${id}`}>
|
||||
<h4>{date}</h4>
|
||||
<h2>{title}</h2>
|
||||
<h3>{`by ${author}`}</h3>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ResearchPage
|
||||
Loading…
Add table
Add a link
Reference in a new issue