Skip to content

Commit 4f9a659

Browse files
committed
タグコンポーネントの分離・フォント変更・その他スタイルの変更
1 parent 72e59cf commit 4f9a659

18 files changed

+153
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: "Mdxで書けるMarkdownのスタイル確認"
3+
date: "2020-12-29-06-56"
4+
tags: [mdx, markdown, blog]
5+
---
6+
7+
これはテスト記事です
8+
- これはテストのテキストです。
9+
- これはThis is a pen;
10+
- React compornent;
11+
- Next.js
12+
13+
# これはテストです React Components - Next.js
14+
15+
`content`
16+
17+
# Code block
18+
```js
19+
console.log('test desu')
20+
const test = getPostData()
21+
```
22+
23+
```ts
24+
import { parse, format } from 'date-fns'
25+
26+
export function formatDate(date: string) {
27+
const fmt = parse(date, 'yyyy-MM-dd-HH-mm', new Date())
28+
// return format(fmt, 'yyyy/MM/dd HH:mm')
29+
return format(fmt, 'yyyy/MM/dd')
30+
}
31+
```

components/ArticleList.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import Link from 'next/link'
2-
import Tags from './Tags'
2+
import TagsInArticleList from './TagsInArticleList'
33
import styles from './styles/articleList.module.scss'
44
import { formatDate } from '../lib/format'
5-
import Articles from '../pages/articles'
65

76
export default function ArticleList(props: {
87
articles: {
@@ -25,8 +24,8 @@ export default function ArticleList(props: {
2524
</Link>
2625
<div className={styles.articleInfo}>
2726
<div className={styles.date}>{formatDate(a.date)}</div>
28-
<div className={styles.separation}> / </div>
29-
<Tags tags={a.tags} />
27+
<div className={styles.separation}>/</div>
28+
<TagsInArticleList tags={a.tags} />
3029
</div>
3130
</div>
3231
)

components/TagsInArticleList.tsx

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Link from 'next/link'
2+
import styles from './styles/tagsInArticleList.module.scss'
3+
4+
export default function Tag(props: {
5+
tags: string[]
6+
}) {
7+
return (
8+
<div className={styles.articleTags}>
9+
{props.tags.map((tag, index) => {
10+
return (
11+
<Link href={`/tags/${tag}`} key={index}>
12+
<a className={styles.tag}>{tag}</a>
13+
</Link>
14+
)
15+
})}
16+
</div>
17+
)
18+
}

components/styles/article.module.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
display: flex;
2121
font-size: 19px;
2222
font-weight: 500;
23+
// font-weight: bold;
2324
color: var(--color-light-text);
2425
letter-spacing: 0.05rem;
2526
align-items: center;
2627
margin-bottom: 0.8rem;
27-
font-family: -apple-system, "Segoe UI", sans-serif;
28+
font-family: 'Roboto', -apple-system, "Segoe UI", sans-serif;
2829
@media screen and (max-width: $breakPoint) {
2930
font-size: 17px;
3031
// font-weight: 400;
@@ -47,7 +48,6 @@
4748
}
4849

4950
.date {
50-
font-family: -apple-system, "Segoe UI", sans-serif;
5151
}
5252

5353
.article {

components/styles/articleList.module.scss

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@
5555
.date {
5656
display: inline-block;
5757
font-size: 16px;
58+
font-weight: 500;
59+
letter-spacing: 0.05rem;
5860
color: var(--color-light-text);
59-
font-family: -apple-system, BlinkMacSystemFont, sans-serif, "Helvetica Neue", "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "ヒラギノ角ゴ ProN W3", Arial, メイリオ, Meiryo;
61+
font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif, "Helvetica Neue", "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "ヒラギノ角ゴ ProN W3", Arial, メイリオ, Meiryo;
6062
// font-weight: 600;
6163
// margin-bottom: 0.2rem;
6264
@media screen and (max-width: $breakPoint) {

components/styles/footer.module.scss

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
width: 100%;
55
// background-color: #fafafa;
66
// color: #bbbbbb;
7+
font-family: 'Roboto', 'Segoe UI', 'Helvetica Neue', Arial, 'BIZ UDPGothic', 'Yu Gothic UI', 'Meiryo UI', Helvetica, sans-serif;
8+
font-weight: 400;
79
padding: 1.8rem 0;
810
border-top: 1px solid var(--color-line);
911
margin-top: auto;
@@ -46,7 +48,7 @@
4648
}
4749

4850
@media screen and (max-width: $breakPoint) {
49-
font-size: 16px;
51+
font-size: 15px;
5052
margin-bottom: .9rem;
5153
order: inherit;
5254
}
@@ -57,7 +59,7 @@
5759
margin-right: 1rem;
5860
order: 1;
5961
@media screen and (max-width: $breakPoint) {
60-
font-size: 16px;
62+
font-size: 15px;
6163
order: inherit;
6264
}
6365
}

components/styles/header.module.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
text-decoration: none;
5353
font-size: 30px;
5454
font-size: 35px;
55-
font-weight: 700;
55+
font-weight: 900;
5656
user-select: none;
5757
@media screen and (max-width: $breakPoint) {
5858
font-size: 25px;

components/styles/tag.module.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
margin-bottom: .5rem;
1717
border-radius: 4px;
1818
text-decoration: none;
19-
// font-weight: 600;
2019
font-size: 19px;
21-
font-family: 'Segoe UI', 'Helvetica Neue', Arial, 'BIZ UDPGothic', 'Yu Gothic UI', 'Meiryo UI', Helvetica, sans-serif;
20+
font-family: 'Roboto', 'Segoe UI', 'Helvetica Neue', Arial, 'BIZ UDPGothic', 'Yu Gothic UI', 'Meiryo UI', Helvetica, sans-serif;
21+
font-weight: 400;
2222
@media screen and (max-width: $breakPoint) {
2323
margin-right: 1.2rem;
2424
margin-bottom: .2rem;

components/styles/taglist.module.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
// color: #0c53c8;
1010
font-size: 18px;
1111
// letter-spacing: 0.08rem;
12-
font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "ヒラギノ角ゴ ProN W3", Arial, メイリオ, Meiryo, sans-serif;
12+
font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "ヒラギノ角ゴ ProN W3", Arial, メイリオ, Meiryo, sans-serif;
13+
font-weight: 500;
1314
}
1415
.tag::marker {
1516
color: var(--color-text);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
@import '../../styles/config';
2+
3+
.articleTags {
4+
margin: 0 0 1rem 0;
5+
// margin-top: 1rem;
6+
// margin-bottom: 3rem;
7+
}
8+
9+
.tag {
10+
display: inline-block;
11+
// background-color: #f1f1f1;
12+
color: var(--color-link);
13+
// padding: 0.3rem 0.8rem;
14+
// margin: 0 0.7rem;
15+
margin-right: 1.3rem;
16+
margin-bottom: .3rem;
17+
border-radius: 4px;
18+
text-decoration: none;
19+
font-weight: 300;
20+
font-size: 17px;
21+
font-family: 'Roboto', 'Segoe UI', 'Helvetica Neue', Arial, 'BIZ UDPGothic', 'Yu Gothic UI', 'Meiryo UI', Helvetica, sans-serif;
22+
letter-spacing: .07rem;
23+
line-height: 1rem;
24+
@media screen and (max-width: $breakPoint) {
25+
margin-right: .8rem;
26+
margin-bottom: .2rem;
27+
font-size: 15px;
28+
}
29+
}
30+
.tag:last-child {
31+
margin-right: 0;
32+
}
33+
.tag:hover {
34+
// background-color: #f6f6f6;
35+
// background-color: #e9e9e9;
36+
// text-decoration: none;
37+
}

gen/articleIds.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"13990": "202009120358_13990_develop-test-3.mdx",
33
"64403": "202008271034_64403_develop-test-1.mdx",
4+
"75234": "202012290656_75234_markdown-style-test.mdx",
45
"80520": "202008301100_80520_develop-test-2.mdx"
56
}

gen/articles.json

+13
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,18 @@
4141
"programming"
4242
]
4343
}
44+
},
45+
{
46+
"slug": "75234",
47+
"fileName": "202012290656_75234_markdown-style-test.mdx",
48+
"fm": {
49+
"title": "Mdxで書けるMarkdownのスタイル確認",
50+
"date": "2020-12-29-06-56",
51+
"tags": [
52+
"mdx",
53+
"markdown",
54+
"blog"
55+
]
56+
}
4457
}
4558
]

gen/tagMap.json

+21
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,26 @@
7575
"title": "本文無しのテスト記事だよ - 3",
7676
"date": "2020-10-04-22-19"
7777
}
78+
],
79+
"mdx": [
80+
{
81+
"slug": "75234",
82+
"title": "Mdxで書けるMarkdownのスタイル確認",
83+
"date": "2020-12-29-06-56"
84+
}
85+
],
86+
"markdown": [
87+
{
88+
"slug": "75234",
89+
"title": "Mdxで書けるMarkdownのスタイル確認",
90+
"date": "2020-12-29-06-56"
91+
}
92+
],
93+
"blog": [
94+
{
95+
"slug": "75234",
96+
"title": "Mdxで書けるMarkdownのスタイル確認",
97+
"date": "2020-12-29-06-56"
98+
}
7899
]
79100
}

lib/format.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import { parse, format } from 'date-fns'
33
export function formatDate(date: string) {
44
const fmt = parse(date, 'yyyy-MM-dd-HH-mm', new Date())
55
// return format(fmt, 'yyyy/MM/dd HH:mm')
6-
return format(fmt, 'yyyy-MM-dd')
6+
return format(fmt, 'MMM d, yyyy')
77
}

lib/getArticle.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import articles from '../gen/articles.json'
22

3-
export function getSortedArticles(limit?: number) {
3+
export function getSortedArticles(limit?: number, tag?: string) {
44

5-
const items = articles.map(article => {
5+
let items = articles.map(article => {
66
return {
77
slug: article.slug,
88
title: article.fm.title,
@@ -20,7 +20,13 @@ export function getSortedArticles(limit?: number) {
2020
})
2121

2222
if (limit) {
23-
return items.slice(0, limit)
23+
items = items.slice(0, limit)
24+
}
25+
26+
if (tag) {
27+
items = items.filter(i => {
28+
return i.tags.includes(tag)
29+
})
2430
}
2531

2632
return items

pages/_document.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export default class MyDocument extends Document {
66
return (
77
<Html lang="ja">
88
<Head>
9-
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@900&Montserrat:wght@700&display=swap" rel="stylesheet" />
9+
<link rel="preconnect" href="https://fonts.gstatic.com" />
10+
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&Orbitron:wght@900&Montserrat:wght@700&display=swap" rel="stylesheet" />
1011
</Head>
1112
<body>
1213
<Main />

pages/tags/[tag].tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const getStaticProps: GetStaticProps = async ({ params }) => {
4545
return {
4646
props: {
4747
tag: tag,
48-
articles: getSortedArticles(),
48+
articles: getSortedArticles(0, tag),
4949
}
5050
}
5151
}

styles/global.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
// Default
44
:root {
55
--color-text: #333333;
6-
--color-light-text: #4c4c4c;
6+
// --color-light-text: #4c4c4c;
7+
--color-light-text: #838383;
78
--color-bg: #fff;
89
--color-link: #0774b5;
910
--color-line: #ededed;

0 commit comments

Comments
 (0)