Skip to content

Commit 1b8849b

Browse files
committed
refactor: migrate content
1 parent 296fcb6 commit 1b8849b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+196
-183
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ Thumbs.db
2525
build/
2626

2727
.env
28+
.astro/

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@
3232
"[typescriptreact]": {
3333
"editor.defaultFormatter": "esbenp.prettier-vscode"
3434
},
35-
"terminal.integrated.defaultProfile.linux": "zsh"
35+
"terminal.integrated.defaultProfile.linux": "zsh",
36+
"[xml]": {
37+
"editor.defaultFormatter": "redhat.vscode-xml"
38+
}
3639
}

src/components/Content.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
import type { MarkdownHeading } from 'astro';
2+
import type { CollectionEntry } from 'astro:content';
23
import path from 'path';
34
import type { ReactNode } from 'react';
45

56
import { EditGitHub } from '@/components/EditGitHub';
67
import { Toc } from '@/components/Toc';
7-
import type { IArticleFrontmatter } from '@/types/IArticleFrontmatter';
88
import { AppConfig } from '@/utils/AppConfig';
99

1010
type IContentProps = {
11-
content: IArticleFrontmatter;
11+
content: CollectionEntry<'posts'>;
1212
headings: MarkdownHeading[];
1313
children: ReactNode;
1414
};
1515

1616
const Content: React.FC<IContentProps> = (props: IContentProps) => {
1717
return (
1818
<div className="mx-auto mt-5 max-w-prose">
19-
{props.content.imgSrc && (
19+
{props.content.data.imgSrc && (
2020
<div className="aspect-w-3 aspect-h-2">
2121
<img
2222
className="h-full w-full rounded-lg object-cover object-center"
23-
src={path.join(AppConfig.base, props.content.imgSrc)}
24-
alt={props.content.imgAlt}
23+
src={path.join(AppConfig.base, props.content.data.imgSrc)}
24+
alt={props.content.data.imgAlt}
2525
loading="lazy"
2626
/>
2727
</div>

src/components/ContentHeader.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
import type { CollectionEntry } from 'astro:content';
12
import { format } from 'date-fns';
23

3-
import type { IArticleFrontmatter } from '@/types/IArticleFrontmatter';
44
import type { Tags } from '@/utils/Tag';
55

66
import { Tag } from './Tag';
77

88
type IContentHeaderProps = {
9-
content: IArticleFrontmatter;
9+
content: CollectionEntry<'posts'>;
1010
author: string;
1111
tags: Tags;
1212
contentCategory: string;
@@ -15,12 +15,12 @@ type IContentHeaderProps = {
1515
export const ContentHeader = (props: IContentHeaderProps) => (
1616
<>
1717
<h1 id="contents_header" className="text-center text-3xl font-bold">
18-
{props.content.title.replace('\\n', '')}
18+
{props.content.data.title.replace('\\n', '')}
1919
</h1>
2020

2121
<div className="mt-2 text-center text-sm text-gray-400">
2222
By {props.author} on{' '}
23-
{format(new Date(props.content.pubDate), 'LLL d, yyyy')}
23+
{format(new Date(props.content.data.pubDate), 'LLL d, yyyy')}
2424
</div>
2525

2626
<div className="mt-4 flex flex-wrap justify-center gap-2">

src/components/EditGitHub.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
import type { CollectionEntry } from 'astro:content';
12
import path from 'path';
23
import { BsGithub } from 'react-icons/bs/index';
34

4-
import type { IArticleFrontmatter } from '@/types/IArticleFrontmatter';
55
import { AppConfig } from '@/utils/AppConfig';
66

77
type IEditGitHubProps = {
8-
content: IArticleFrontmatter;
8+
content: CollectionEntry<'posts'>;
99
};
1010

1111
export const EditGitHub = (props: IEditGitHubProps) => {
12-
if (props.content.url === undefined) {
12+
if (props.content.id === undefined) {
1313
return <></>;
1414
}
1515

@@ -19,14 +19,14 @@ export const EditGitHub = (props: IEditGitHubProps) => {
1919
'main',
2020
'src',
2121
'pages',
22-
props.content.url
22+
props.content.id
2323
);
2424

2525
return (
2626
<div className="flex justify-end">
2727
<a
2828
style={{ height: 'fit-content' }}
29-
href={`https://${url}.md`}
29+
href={`https://${url}`}
3030
target="_blank"
3131
rel="noopener noreferrer"
3232
>

src/components/PostCard.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
import { format } from 'date-fns';
22
import path from 'path';
33

4-
import type { IContent } from '@/types/IArticleFrontmatter';
4+
import type { IPost } from '@/types/IArticleFrontmatter';
55
import { AppConfig } from '@/utils/AppConfig';
66
import { transformTitleForContentCard } from '@/utils/StringWidth';
77
import type { Tags } from '@/utils/Tag';
88

99
import { Tag } from './Tag';
1010

1111
type IPostCardProps = {
12-
instance: IContent;
12+
instance: IPost;
1313
contentCategory: string;
1414
tags: Tags;
1515
};
1616

1717
export const PostCard = (props: IPostCardProps) => {
18-
const contentPath = props.instance.url;
18+
const contentPath = path.join(
19+
'/',
20+
props.instance.collection,
21+
props.instance.slug
22+
);
1923

2024
return (
2125
<div className="relative overflow-hidden rounded-md bg-slate-800">
2226
<div className="aspect-w-16 aspect-h-9">
23-
{props.instance.frontmatter.imgSrc && (
27+
{props.instance.data.imgSrc && (
2428
<img
2529
className="h-full w-full object-cover object-center"
26-
src={path.join(AppConfig.base, props.instance.frontmatter.imgSrc)}
27-
alt={props.instance.frontmatter.imgSrc}
30+
src={path.join(AppConfig.base, props.instance.data.imgSrc)}
31+
alt={props.instance.data.imgSrc}
2832
loading="lazy"
2933
/>
3034
)}
@@ -35,7 +39,7 @@ export const PostCard = (props: IPostCardProps) => {
3539
<div className="py-1.5 px-3">
3640
<a href={contentPath}>
3741
<div>
38-
{transformTitleForContentCard(props.instance.frontmatter.title)
42+
{transformTitleForContentCard(props.instance.data.title)
3943
.split('\\n')
4044
.map((t) => (
4145
<span key={t} className="text-lg font-bold">
@@ -44,16 +48,13 @@ export const PostCard = (props: IPostCardProps) => {
4448
</span>
4549
))}
4650
<span className="align-middle text-xs text-gray-300 ">
47-
{format(
48-
new Date(props.instance.frontmatter.pubDate),
49-
'LLL d, yyyy'
50-
)}
51+
{format(new Date(props.instance.data.pubDate), 'LLL d, yyyy')}
5152
</span>
5253
</div>
5354
</a>
5455
<div className="mt-1 flex flex-wrap gap-2">
55-
{props.instance.frontmatter.tags &&
56-
props.instance.frontmatter.tags.map((tagName) => (
56+
{props.instance.data.tags &&
57+
props.instance.data.tags.map((tagName) => (
5758
<Tag
5859
key={tagName}
5960
name={tagName}

src/components/PostGallery.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import type { IContent } from '@/types/IArticleFrontmatter';
1+
import type { IPost } from '@/types/IArticleFrontmatter';
22
import type { Tags } from '@/utils/Tag';
33

44
import { PostCard } from './PostCard';
55

66
type IRecentPostsProps = {
77
tags: Tags;
88
contentCategory: string;
9-
postList: IContent[];
9+
postList: IPost[];
1010
};
1111

1212
export const PostGallery = (props: IRecentPostsProps) => {
1313
return (
1414
<div className="grid grid-cols-1 gap-6 md:grid-cols-3">
1515
{props.postList.map((elt) => (
1616
<PostCard
17-
key={elt.url}
17+
key={elt.id}
1818
instance={elt}
1919
tags={props.tags}
2020
contentCategory={props.contentCategory}

src/content/config.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { defineCollection, z } from 'astro:content';
2+
3+
const postCollection = defineCollection({
4+
schema: z.object({
5+
title: z.string(),
6+
description: z.string().nullable().optional(),
7+
pubDate: z.date(),
8+
tags: z.array(z.string()),
9+
order: z.number().optional(),
10+
imgSrc: z.string().optional(),
11+
imgAlt: z.string().optional(),
12+
draft: z.boolean().optional(),
13+
}),
14+
});
15+
16+
export const collections = {
17+
posts: postCollection,
18+
};
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: ETロボコン2017 に参加しました
44
description: ロボコンの話
55
pubDate: 2017-09-30T00:00:00Z
@@ -8,7 +8,7 @@ tags:
88
- 大学
99
---
1010

11-
片山徹郎研究室のメンバーで参加しました。九州南地区大会で敗北。
11+
片山徹郎研究室のメンバーで参加しました。九州南地区大会で敗北。aaa
1212

1313
- [ETロボコン2017大会 | ETロボコン](https://www.etrobo.jp/2017archive)
1414
- [korosuke613/etrobocon2017: ETロボコン2017](https://github.com/korosuke613/etrobocon2017)

src/pages/posts/20171001_senmon.md renamed to src/content/posts/20171001_senmon.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: 専門教育入門セミナーT 2017\nin 片山(徹)研
44
description: 授業の話
55
pubDate: 2017-10-01T00:00:00Z

src/pages/posts/20180926_jceee2018.md renamed to src/content/posts/20180926_jceee2018.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: 'JCEEE 2018で論文を発表しました'
44
description: '学会の話'
55
pubDate: 2018-09-26T00:00:00Z

src/pages/posts/20180928_etrobocon2018.md renamed to src/content/posts/20180928_etrobocon2018.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: ETロボコン2018 九州南大会優勝!
44
description: ロボコンの話
55
pubDate: 2018-09-28T00:00:00Z

src/pages/posts/20181114_etrobocon2018_ca.md renamed to src/content/posts/20181114_etrobocon2018_ca.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: ETロボコン2018 全国大会\n14チーム中8位!
44
description: ロボコンの話
55
pubDate: 2018-11-14T00:00:00Z

src/pages/posts/20190110_icarob2019.md renamed to src/content/posts/20190110_icarob2019.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: 'ICAROB2019(査読有り) 論文発表'
44
description: '論文発表の話'
55
pubDate: 2019-01-10T00:00:00Z

src/pages/posts/20190330_intern.md renamed to src/content/posts/20190330_intern.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: 'リクルートライフスタイルさんの\nインターンに参加しました'
44
description: 'インターンの話'
55
pubDate: 2019-03-30T00:00:00Z

src/pages/posts/20190829_ses2019.md renamed to src/content/posts/20190829_ses2019.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: 'SES2019(査読有り) 論文発表'
44
description: '学会の話'
55
pubDate: 2019-08-29T00:00:00Z

src/pages/posts/20190928_etrobo2019_minami.md renamed to src/content/posts/20190928_etrobo2019_minami.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: 'ETロボコン2019 九州南大会\n(総合優勝、IPA賞!)'
44
description: 'ロボコンの話'
55
pubDate: 2019-09-28T00:00:00Z

src/pages/posts/20191120_etrobo2019_ca.md renamed to src/content/posts/20191120_etrobo2019_ca.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: 'ETロボコン2019全国大会出場\n(モデルランクB!)'
44
description: 'ロボコンの話'
55
pubDate: 2019-11-20T00:00:00Z

src/pages/posts/20200324_graduate_miyazaki_u.md renamed to src/content/posts/20200324_graduate_miyazaki_u.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: '宮崎大学大学院を\n修了しました'
44
description: '修了の話'
55
pubDate: 2020-03-24T00:00:00Z

src/pages/posts/20200401_join_cybozu.md renamed to src/content/posts/20200401_join_cybozu.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: 'サイボウズ株式会社に\n入社しました'
44
description: '就職の話'
55
pubDate: 2020-04-01T00:00:00Z

src/pages/posts/20220826_cybozu_insideout_devsumi.md renamed to src/content/posts/20220826_cybozu_insideout_devsumi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: '生産性向上は一筋縄ではいかない Q&A [デブサミ2022夏]'
44
description: ''
55
pubDate: 2022-08-26T00:00:00Z

src/pages/posts/20230103_hofu_.md renamed to src/content/posts/20230103_hofu_.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: '2023年の抱負を書きました'
44
description: ''
55
pubDate: 2023-01-03T00:00:00Z

src/pages/posts/compare-renovate-logs.md renamed to src/content/posts/compare-renovate-logs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: 'compare-renovate-logs'
44
description: ''
55
pubDate: 2022-12-23T00:00:00Z

src/pages/posts/history.md renamed to src/content/posts/history.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
layout: '@/templates/BasePost.astro'
32
title: 自己紹介
43
description: 平木場ヒストリー
54
pubDate: 2022-08-21T00:00:00Z

src/pages/posts/info_from_amazon.md renamed to src/content/posts/info_from_amazon.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: 'book-info-from-amazon'
44
description: ''
55
pubDate: 2017-06-13T00:00:00Z

src/pages/posts/miyadai_network_auto_login.md renamed to src/content/posts/miyadai_network_auto_login.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: miyadai-sso-auto-login
44
description: 宮崎大学の学内ネットワーク接続時に自動でログインするツール
55
pubDate: 2018-08-15T00:00:00Z

src/pages/posts/miyadai_shienka_oshirase_bot.md renamed to src/content/posts/miyadai_shienka_oshirase_bot.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: 宮大支援課お知らせBOT【非公式】
44
description: 宮崎大学 学生生活支援課の情報をツイートする Bot
55
pubDate: 2017-06-13T00:00:00Z

src/pages/posts/pict4java.md renamed to src/content/posts/pict4java.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: pict4java
44
description: PICT を Java/Kotlin から利用する JNA クラス pict4java
55
pubDate: 2018-07-15T00:00:00Z

src/pages/posts/productivity_weekly.md renamed to src/content/posts/productivity_weekly.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: Productivity Weekly
44
description: 「開発者の生産性向上に関するネタを共有する会」で出たネタを毎週発信
55
pubDate: 2020-11-17T00:00:00Z

src/pages/posts/sixth-post.md renamed to src/content/posts/sixth-post.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: あのイーハトーヴォのすきとおった風、夏でも底に冷たさをもつ青いそら、うつくしい森で飾られたモリーオ市、郊外のぎらぎらひかる草の波。またそのなかでいっしょになったたくさんのひとたち、ファゼーロ
44
description: Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi.
55
pubDate: 1900-02-06T00:00:00Z

src/pages/posts/template.md renamed to src/content/posts/template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: '@/templates/BasePost.astro'
2+
33
title: 'aaa'
44
description: ''
55
pubDate: 2017-06-13T00:00:00Z

0 commit comments

Comments
 (0)