-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from taga3s/feat/blogs-page
feat: posts
- Loading branch information
Showing
15 changed files
with
2,600 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
type Post = { | ||
id: string; | ||
title: string; | ||
publishedAt: string; | ||
}; | ||
|
||
export type { Post }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { css } from "hono/css"; | ||
|
||
const postsStyle = { | ||
wrapper: css` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 16px; | ||
margin-top: 32px; | ||
`, | ||
item: css` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 8px; | ||
width: 100%; | ||
padding: 16px; | ||
border: 1px solid #ccc; | ||
border-radius: 8px; | ||
`, | ||
itemTitle: css` | ||
font-size: 20px; | ||
font-weight: bold; | ||
`, | ||
}; | ||
|
||
export { postsStyle }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { FC } from "hono/jsx"; | ||
import type { Post } from "../../api/posts/model"; | ||
import { Section } from "../Section"; | ||
import { postsStyle } from "./Posts.css"; | ||
|
||
type Props = { | ||
posts: Post[]; | ||
}; | ||
|
||
const Posts: FC<Props> = ({ posts }) => { | ||
return ( | ||
<Section title="Posts"> | ||
<div class={postsStyle.wrapper}> | ||
{posts.map((post) => { | ||
return ( | ||
<a key={post.id} href={`/${post.id}`} class={postsStyle.item}> | ||
<span>{post.publishedAt}</span> | ||
<span class={postsStyle.itemTitle}>{post.title}</span> | ||
</a> | ||
); | ||
})} | ||
</div> | ||
</Section> | ||
); | ||
}; | ||
|
||
export { Posts }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { FC } from "hono/jsx"; | ||
import { Posts } from "./Posts"; | ||
import type { Post } from "../../api/posts/model"; | ||
|
||
type Props = { | ||
posts: Post[]; | ||
}; | ||
|
||
const PostsPresenter: FC<Props> = ({ posts }) => { | ||
return <Posts posts={posts} />; | ||
}; | ||
|
||
export { PostsPresenter }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,9 @@ const bodyLayout = css` | |
const HeaderMemorized = memo(() => <Header />); | ||
const FooterMemorized = memo(() => <Footer />); | ||
|
||
export default jsxRenderer(({ children }) => { | ||
export default jsxRenderer(({ children, title }) => { | ||
const _title = title ?? "taga3s-dev"; | ||
|
||
return ( | ||
<html lang="ja" class={htmlLayout}> | ||
<head> | ||
|
@@ -39,11 +41,15 @@ export default jsxRenderer(({ children }) => { | |
|
||
{/* reset css */} | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/destyle.css" /> | ||
|
||
{/* global css */} | ||
<link rel="stylesheet" href="/static/markdown-styles.css" /> | ||
<Style /> | ||
|
||
<Script src="/app/client.ts" async /> | ||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, user-scalable=yes" /> | ||
<title>taga3s-dev</title> | ||
<title>{_title}</title> | ||
</head> | ||
<body class={bodyLayout}> | ||
<ErrorBoundary fallback={<p>Sorry, Out of Service.</p>}> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createRoute } from "honox/factory"; | ||
import { PostsPresenter } from "../components/posts/PostsPresenter"; | ||
|
||
export type Meta = { | ||
title: string; | ||
publishedAt: string; | ||
}; | ||
|
||
export default createRoute(async (c) => { | ||
const rawPosts = import.meta.glob<{ frontmatter: Meta }>("./posts/*.mdx", { | ||
eager: true, | ||
}); | ||
const posts = Object.entries(rawPosts).map(([id, module]) => ({ | ||
id: id.replace(/\.mdx$/, ""), | ||
title: module.frontmatter.title ?? "", | ||
publishedAt: module.frontmatter.publishedAt ?? "", | ||
})); | ||
|
||
return c.render(<PostsPresenter posts={posts} />); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { jsxRenderer } from "hono/jsx-renderer"; | ||
|
||
export default jsxRenderer(({ children, Layout, frontmatter }) => { | ||
return ( | ||
<Layout title={frontmatter?.title}> | ||
<article class="markdown-body">{children}</article> | ||
</Layout> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
title: "Markdown試し打ち" | ||
publishedAt: "2024-09-XX" | ||
--- | ||
|
||
# # Markdown試し打ち | ||
|
||
これはMarkdownの試し打ちです。適宜チューニングしていきたい。以下、怪文書が続きます。 | ||
|
||
## ## Section 1 | ||
|
||
**以下は、法学部の生徒が学ぶ代表的な法律の分野です。** | ||
|
||
- 刑法 | ||
- 民法 | ||
- 民法総則 | ||
- 債権総論 | ||
- etc... | ||
- 憲法 | ||
|
||
とある法学部の学生が、法律の勉強をしているときに、次のような名言を思い出しました。 | ||
|
||
> Sweet are the uses of adversity, Which, like the toad, ugly and venomous, Wears yet a precious jewel in his head. | ||
> | ||
> Shakespeare | ||
### ### Section 2 | ||
|
||
~ねこ~ いぬ(w300 * h200) | ||
<img width="300" height="200" src="https://images.dog.ceo/breeds/terrier-welsh/lucy.jpg" /> | ||
|
||
動物の画像を表示してみました。 | ||
- [ ] 犬はkawaii | ||
- [x] 猫もkawaii | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.