Skip to content

Commit

Permalink
feat: build blog
Browse files Browse the repository at this point in the history
  • Loading branch information
mrryk committed Aug 12, 2023
1 parent 43ca959 commit 15bbd60
Show file tree
Hide file tree
Showing 19 changed files with 1,853 additions and 191 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.md
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"tabWidth": 2
}
13 changes: 13 additions & 0 deletions _posts/recently.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: 近況について
date: '2023-8-6'
---

## 転職

この度、雑務エンジニアからWebエンジニアへと転職をしました。

SEとしてアサインされたものの実態はドキュメントの作成やテストやエビデンスを貼り付けなど雑務がメインでした。
スキルアップは望めないと感じ、Webサービスの開発を行っている会社へ転職しました。

現在では、**Next.js Fastify**を使用してフロントエンドからバックエンドまで幅広く開発を行っています。
21 changes: 21 additions & 0 deletions lib/get-all-posts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import fs from 'fs'
import { join } from 'path'
import { getPostContent } from './get-post-content'
const dirPath = join(process.cwd(), '_posts')

export const getAllPosts = () => {
const slugs = fs.readdirSync(dirPath)
const posts = slugs.map((s, _) => {
const slug = s.replace(/\.md$/, '')
const { data } = getPostContent(`_posts/${slug}.md`)
return {
slug,
data,
}
})

posts.sort((post1, post2) =>
post1.data['date'] > post2.data['date'] ? -1 : 1
)
return posts
}
7 changes: 7 additions & 0 deletions lib/get-all-slug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import fs from 'fs'
import { join } from 'path'
const dirPath = join(process.cwd(), '_posts')

export const getAllSlugs = () => {
return fs.readdirSync(dirPath).map((f) => f.replace(/\.md$/, ''))
}
10 changes: 10 additions & 0 deletions lib/get-post-content.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as fs from 'fs'
import matter from 'gray-matter'
export const getPostContent = (fileName: string) => {
const contents = fs.readFileSync(fileName, 'utf-8')
const { data, content } = matter(contents)
return {
data,
content,
}
}
Empty file added lib/get-post-data.ts
Empty file.
8 changes: 8 additions & 0 deletions lib/markdown-to-html.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { remark } from 'remark'
import remarkGfm from 'remark-gfm'
import remarkHtml from 'remark-html'

export const markdownToHtml = async (content: string) => {
const result = await remark().use(remarkGfm).use(remarkHtml).process(content)
return result.toString()
}
Loading

0 comments on commit 15bbd60

Please sign in to comment.