Skip to content

Commit eb8c91d

Browse files
authored
[Feature] Added updatedAt attribute in blog meta (#152)
* Added updatedAt attribute in blog meta * chore: Update actions version for ci * chore: update node version to 20, pnpm to 9.x.x * Used builtin cancel-in-progress instead of styfle/cancel-workflow-action * Changed wording to 'Last Updated' from 'Updated' * Added examples for date formats in documentation
1 parent f1ae77b commit eb8c91d

File tree

9 files changed

+2217
-1774
lines changed

9 files changed

+2217
-1774
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout
12-
uses: actions/checkout@v3
12+
uses: actions/checkout@v4
1313
- name: Setup pnpm
14-
uses: pnpm/action-setup@v2.2.2
14+
uses: pnpm/action-setup@v4
1515
with:
16-
version: 7.x.x
16+
version: 9.x.x
1717
- name: Setup NodeJS
18-
uses: actions/setup-node@v3
18+
uses: actions/setup-node@v4
1919
with:
20-
node-version: '16'
20+
node-version: '20'
2121
cache: 'pnpm'
2222
- name: Install dependencies
2323
run: pnpm install --frozen-lockfile

.github/workflows/ci.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,21 @@ name: CI
99
jobs:
1010
lint:
1111
runs-on: ubuntu-latest
12+
concurrency:
13+
group: ${{ github.ref }}
14+
cancel-in-progress: true
1215
steps:
13-
- name: Cancel previous runs
14-
uses: styfle/cancel-workflow-action@0.9.1
15-
with:
16-
all_but_latest: true
17-
access_token: ${{ secrets.GITHUB_TOKEN }}
18-
1916
- name: Checkout
20-
uses: actions/checkout@v3
17+
uses: actions/checkout@v4
2118

22-
- uses: pnpm/action-setup@v2.2.2
19+
- uses: pnpm/action-setup@v4
2320
with:
24-
version: 7.x.x
21+
version: 9.x.x
2522

2623
- name: Setup NodeJS
27-
uses: actions/setup-node@v3
24+
uses: actions/setup-node@v4
2825
with:
29-
node-version: '16'
26+
node-version: '20'
3027
cache: 'pnpm'
3128

3229
- name: Install dependencies

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ A beautiful blogging platform for the JankariTech peoples.
2929
authorName: John Doe
3030
authorAvatar: https://some.link.jpg (must be an image URL, **required**)
3131
authorLink: https://github.com/John
32-
createdAt: Oct 30, 2019 (must be in the format `MM dd, yyyy`, **required**)
32+
createdAt: Oct 30, 2019 (must be in the format `MMM dd, yyyy` e.g., `Oct 30, 2019` or `MMMM dd, yyyy` e.g., `October 30, 2019`, **required**)
33+
updatedAt: Oct 30, 2023 (must be in the format `MMM dd, yyyy` e.g., `Oct 30, 2023` or `MMMM dd, yyyy` e.g., `October 30, 2023`, **optional**)
3334
tags: vue, jest, unit, testing (separate multiple items with a comma `,` character, **required**)
3435
banner: https://some.link.jpg (must be an image URL, **required**)
3536
seriesTitle: Unit Testing is Fun (if only this post belongs to a series, **optional**)

lint/check.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const requiredMeta = [
4242
]
4343

4444
const optionalMeta = [
45+
"updatedAt",
4546
"seriesTitle",
4647
"episode"
4748
]
@@ -91,11 +92,28 @@ function lintMeta (key) {
9192
})
9293

9394
// check if the createdAt is set with proper format
95+
let createdAt
9496
if (peekData.createdAt) {
95-
const regex = /[A-Za-z]+\s\d{1,2},\s\d{4}/g
97+
createdAt = new Date(peekData.createdAt)
98+
if (isNaN(createdAt.getTime())) {
99+
log.error(`Invalid createdAt date format in ${key}`)
100+
success = false
101+
}
102+
}
96103

97-
if (!regex.test(peekData.createdAt)) {
98-
log.error(`Invalid date format in ${key}`)
104+
if (peekData.updatedAt) {
105+
const updatedAt = new Date(peekData.updatedAt)
106+
// check if the updatedAt is set with proper format
107+
if (isNaN(updatedAt.getTime())) {
108+
log.error(`Invalid updatedAt date format in ${key}`)
109+
success = false
110+
}
111+
// check if the updatedAt is later than createdAt
112+
if (createdAt.getTime() === updatedAt.getTime()) {
113+
log.error(`Updated date is same as created date in ${key}`)
114+
success = false
115+
} else if (createdAt.getTime() > updatedAt.getTime()) {
116+
log.error(`Updated date is earlier than created date in ${key}`)
99117
success = false
100118
}
101119
}

0 commit comments

Comments
 (0)