Skip to content

Commit 0a22b73

Browse files
committed
First commit.
1 parent f0209fd commit 0a22b73

26 files changed

+1641
-263
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

3+
# nedew.dev
4+
/tmp_doc
5+
36
# dependencies
47
/node_modules
58
/.pnp

README.md

+5-30
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,5 @@
1-
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2-
3-
## Getting Started
4-
5-
First, run the development server:
6-
7-
```bash
8-
npm run dev
9-
# or
10-
yarn dev
11-
```
12-
13-
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
14-
15-
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
16-
17-
## Learn More
18-
19-
To learn more about Next.js, take a look at the following resources:
20-
21-
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
22-
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
23-
24-
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
25-
26-
## Deploy on Vercel
27-
28-
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/import?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
29-
30-
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
1+
# Blog
2+
- Next.js
3+
- SSG
4+
- MDX
5+
- YAML Front Matter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: "Test MDX Document No.1"
3+
date: "2020-10-02"
4+
---
5+
6+
# Test MDX Document No.1
7+
これはテスト記事です
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: "Test MDX Document No.2"
3+
date: "2020-10-03"
4+
---
5+
6+
# Test MDX Document No.2
7+
これはテスト記事です
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: "Test MDX Document No.3"
3+
date: "2020-10-04"
4+
---
5+
6+
# Test MDX Document No.3
7+
これはテスト記事です

components/Article.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export default function Article(props: {
2+
children: React.ReactNode
3+
title: string
4+
date: string
5+
}) {
6+
return (
7+
<>
8+
<h1>{props.title}</h1>
9+
<div>{props.date}</div>
10+
<article>
11+
{props.children}
12+
</article>
13+
</>
14+
)
15+
}

components/Layout.tsx

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import Head from 'next/head'
2+
import styles from './layout.module.scss'
3+
4+
export default function Layout({
5+
children
6+
}: {
7+
children: React.ReactNode
8+
}) {
9+
return (
10+
<>
11+
<Head>
12+
<link rel="icon" href="/favicon.ico" />
13+
<meta
14+
name="description"
15+
content="My Blog"
16+
/>
17+
</Head>
18+
<header className={styles.header}>
19+
<div>This is header!</div>
20+
</header>
21+
<main className={styles.container}>{children}</main>
22+
<footer className={styles.footer}>
23+
<div>This is footer?</div>
24+
</footer>
25+
</>
26+
)
27+
}

components/layout.module.scss

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.header {
2+
width: 100%;
3+
background-color: black;
4+
color: #ffffff;
5+
padding: 1.5rem 0;
6+
}
7+
8+
.footer {
9+
width: 100%;
10+
background-color: black;
11+
color: #ffffff;
12+
padding: 1.5rem 0;
13+
}
14+
15+
.container {
16+
max-width: 40rem;
17+
padding: 0 1rem;
18+
margin: 3rem auto 6rem;
19+
}

gen/articleIds.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"13857": "202009120358_13857_develop-test-3.mdx",
3+
"62426": "202008271034_62426_develop-test-1.mdx",
4+
"89546": "202008301100_89546_develop-test-2.mdx"
5+
}

gen/articles.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[
2+
{
3+
"slug": "62426",
4+
"fileName": "202008271034_62426_develop-test-1.mdx",
5+
"fm": {
6+
"title": "Hello, World!",
7+
"date": "2020-01-01"
8+
}
9+
},
10+
{
11+
"slug": "89546",
12+
"fileName": "202008301100_89546_develop-test-2.mdx",
13+
"fm": {
14+
"title": "Hello, World!",
15+
"date": "2020-01-01"
16+
}
17+
},
18+
{
19+
"slug": "13857",
20+
"fileName": "202009120358_13857_develop-test-3.mdx",
21+
"fm": {
22+
"title": "Hello, World!",
23+
"date": "2020-01-01"
24+
}
25+
}
26+
]

lib/articles.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import fs from 'fs'
2+
import path from 'path'
3+
import articleIds from '../gen/articleIds.json'
4+
5+
const articlesDir = path.join(process.cwd(), 'articles')
6+
7+
export function getSortedPostsData() {
8+
9+
}
10+
11+
export function getAllSlug() {
12+
return Object.keys(articleIds).map(id => {
13+
console.log(id)
14+
return {
15+
params: {
16+
slug: id
17+
}
18+
}
19+
})
20+
}

lib/fm-loader.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const matter = require('gray-matter')
2+
const stringifyObject = require('stringify-object')
3+
module.exports = async function (src) {
4+
const callback = this.async()
5+
const {content, data} = matter(src)
6+
const code = `export const frontMatter = ${stringifyObject(data)}
7+
${content}`
8+
return callback(null, code)
9+
}

next-env.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/types/global" />

next.config.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const path = require("path")
2+
3+
module.exports = {
4+
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'],
5+
webpack: (config, options) => {
6+
config.resolve.alias["@/*"] = path.resolve(__dirname, "./*")
7+
config.module.rules.push({
8+
test: /\.mdx?$/,
9+
use: [
10+
options.defaultLoaders.babel,
11+
"@mdx-js/loader",
12+
path.join(__dirname, "./lib/fm-loader"),
13+
],
14+
})
15+
16+
return config
17+
},
18+
}

0 commit comments

Comments
 (0)