Skip to content

Commit 983c147

Browse files
committed
Add multi-line message support to changelog
1 parent a8c94d0 commit 983c147

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

pages/changelog.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import gitRawCommits from "git-raw-commits"
2+
import { GetStaticPropsContext, GetStaticPropsResult } from "next"
13
import Head from "next/head"
2-
import Main from "../components/Main"
34
import FormattedLink from "../components/FormattedLink"
4-
import { GetStaticPropsContext, GetStaticPropsResult } from "next"
5-
import gitRawCommits from "git-raw-commits"
5+
import Main from "../components/Main"
66

77
interface CommitData {
88
hash: string
@@ -47,9 +47,14 @@ export default function Changelog({ location, commits }: { location: string } &
4747
}
4848

4949
function Commit({ commit, prev }: { commit: CommitData, prev?: CommitData }) {
50-
const child = <span>{commit.message}</span>
51-
const date = new Date(commit.timestamp)
50+
const child = <span>{commit.message.split("\n").map((v, i, a) =>
51+
<span key={i} className={i == 0 ? "font-semibold" : "font-normal pl-4"}>
52+
{v}
53+
{i == a.length - 1 || <br />}
54+
</span>
55+
)}</span>
5256

57+
const date = new Date(commit.timestamp)
5358
const formattedDate = date.toLocaleString("en-UK", {
5459
month: "long",
5560
day: "numeric",
@@ -95,7 +100,7 @@ export async function getStaticProps(context: GetStaticPropsContext): Promise<Ge
95100
return {
96101
hash: commit.sha,
97102
timestamp: new Date(commit.commit.committer.date).getTime(),
98-
message: commit.commit.message.split("\n")[0].trim(),
103+
message: commit.commit.message.replace(/\n\n/g, "\n").trim(),
99104
type: "Bot/Data"
100105
}
101106
})
@@ -116,7 +121,7 @@ export async function getStaticProps(context: GetStaticPropsContext): Promise<Ge
116121
return {
117122
hash,
118123
timestamp,
119-
message: split.join("|").split("\n")[0].trim(),
124+
message: split.join("|").replace(/\n\n/g, "\n").trim(),
120125
type: "Website"
121126
}
122127
})

0 commit comments

Comments
 (0)