Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Commit 21afef6

Browse files
committed
Merge branch 'main' into release
2 parents a3b361f + f0abc49 commit 21afef6

File tree

9 files changed

+407
-209
lines changed

9 files changed

+407
-209
lines changed

Diff for: app/_component/sections/notice/Announce.tsx

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import NoticeCard from "./Card";
2+
import { getNotices } from "@/components/loadFiles";
3+
import { css } from "@/styled-system/css";
4+
5+
export default function Notice() {
6+
const notices = getNotices();
7+
// ビルド時点での期限が過ぎたお知らせは表示しないï
8+
const displayNotices = notices.filter(
9+
(n) => n.deadline.getTime() > Date.now(),
10+
);
11+
12+
return (
13+
<section
14+
className={css({
15+
padding: "50px 0",
16+
textAlign: "center",
17+
})}
18+
>
19+
<h2
20+
className={css({
21+
paddingBottom: "30px",
22+
fontSize: "2rem",
23+
})}
24+
>
25+
お知らせ
26+
</h2>
27+
28+
<div
29+
className={css({
30+
marginInline: "auto",
31+
maxWidth: "800px",
32+
})}
33+
>
34+
{displayNotices.map((notice) => (
35+
<NoticeCard key={notice.id} notice={notice} />
36+
))}
37+
</div>
38+
</section>
39+
);
40+
}

Diff for: app/_component/sections/notice/Card.tsx

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"use client";
2+
3+
import Md2Html from "@/components/md2html";
4+
import { formatdate } from "@/components/util";
5+
import { css } from "@/styled-system/css";
6+
import { mdStyle } from "@/styled-system/patterns";
7+
import { NoticePage } from "@/types";
8+
9+
type Props = {
10+
notice: NoticePage;
11+
};
12+
13+
export default function NoticeCard(props: Props) {
14+
const { notice } = props;
15+
16+
const now = Date.now();
17+
18+
return (
19+
<div
20+
key={notice.id}
21+
className={css({
22+
padding: "40px",
23+
textAlign: "start",
24+
borderBottom: "1px solid rgba(0, 0, 0, 0.2)",
25+
26+
"&:nth-child(1)": {
27+
borderTop: "1px solid rgba(0, 0, 0, 0.2)",
28+
},
29+
})}
30+
// 期限が過ぎたお知らせは非表示
31+
style={{ display: now < notice.deadline.getTime() ? "block" : "none" }}
32+
>
33+
<p>
34+
<span>{formatdate(notice.meta.created_at)}</span>
35+
<span
36+
className={css({
37+
marginLeft: "10px",
38+
})}
39+
>
40+
[{notice.category}]
41+
</span>
42+
</p>
43+
44+
<h3
45+
className={css({
46+
fontSize: "1.5rem",
47+
fontWeight: "bold",
48+
})}
49+
>
50+
{notice.meta.title}
51+
</h3>
52+
53+
<Md2Html
54+
className={mdStyle({
55+
style: "a-only",
56+
})}
57+
content={notice.content}
58+
/>
59+
</div>
60+
);
61+
}

Diff for: app/page.tsx

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
1-
import AboutSection from './_component/sections/About';
2-
import ImageSection from './_component/sections/Image';
3-
import RecentPosts from './_component/sections/recentpost/RecentPosts';
4-
import TopSection from './_component/sections/top/Top';
5-
import { getPages, getPosts, getTopImages } from '@/components/loadFiles';
1+
import AboutSection from "./_component/sections/About";
2+
import ImageSection from "./_component/sections/Image";
3+
import Notice from "./_component/sections/notice/Announce";
4+
import RecentPosts from "./_component/sections/recentpost/RecentPosts";
5+
import TopSection from "./_component/sections/top/Top";
6+
import { getPages, getPosts, getTopImages } from "@/components/loadFiles";
67

78
export default function Home() {
89
const pages = getPages();
910
const posts = getPosts();
1011

11-
const topPage = pages.find((page) => page.path === '/');
12-
const mdContents = topPage ? topPage.content.split('---') : [];
12+
const topPage = pages.find((page) => page.path === "/");
13+
const mdContents = topPage ? topPage.content.split("---") : [];
1314
const imagepathes = getTopImages();
1415
const hero =
15-
imagepathes.find((image) => image.name.startsWith('hero')) ||
16+
imagepathes.find((image) => image.name.startsWith("hero")) ||
1617
imagepathes.slice(-1)[0];
1718
const others = imagepathes.filter((image) => image.name !== hero.name);
1819

1920
return (
2021
<main>
2122
<TopSection message={mdContents[0]} images={[hero, ...others]} />
23+
<Notice />
24+
<ImageSection img={imagepathes[0].path} />
2225
<RecentPosts posts={posts} />
2326
{mdContents.splice(1).map((content, index) => {
2427
return (
2528
<>
2629
<ImageSection
2730
key={`parallax-${index}`}
28-
img={imagepathes[index % imagepathes.length].path}
31+
img={imagepathes[(index + 1) % imagepathes.length].path}
2932
/>
3033
<AboutSection key={index} content={content} />
3134
</>

0 commit comments

Comments
 (0)