forked from juneHQ/changelog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew-changelog.sh
executable file
·59 lines (46 loc) · 1.28 KB
/
new-changelog.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <release-name> <year-month-day> <hour:minute>"
echo "Example: $0 \"New Homepage\" 2024-06-10 14:30"
exit 1
fi
# Get the release name from parameter
RELEASE=$1
# format release into loewrcase and replace spaces with dashes
RELEASE_TITLE=$(echo $RELEASE | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
# Get the date from parameter
DATE=$2
# Get the relase hour from parameter
HOUR=$3
filename=$DATE-$RELEASE_TITLE
filepath="./pages/changelogs/$filename.mdx"
# Check if the file already exists
if [[ -e $filepath ]]; then
echo "File $filepath already exists"
exit 1
fi
# Create the file
touch $filepath
# create the changelog file from template
cat > $filepath << EOF
import { MdxLayout } from "components/mdx-layout.tsx";
export const meta = {
slug: "$DATE-$RELEASE",
publishedAt: "$DATET$HOUR:00.000Z",
title: "$RELEASE",
headerImage: \`\${process.env.NEXT_PUBLIC_APP_HOST}/imgs/response-expiration.png\`,
authors: [
{
name: "Samuel Berthe",
description: "Cofounder",
avatarUrl: \`\${process.env.NEXT_PUBLIC_APP_HOST}/authors/samuel-berthe.png\`,
},
],
};
Content of the release
export default ({ children, ...rest }) => (
<MdxLayout meta={meta} {...rest}>
{children}
</MdxLayout>
);
EOF