Skip to content

Commit

Permalink
[Feature] Added updatedAt attribute in blog meta (#152)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
grgprarup authored Jul 8, 2024
1 parent f1ae77b commit eb8c91d
Show file tree
Hide file tree
Showing 9 changed files with 2,217 additions and 1,774 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.2
uses: pnpm/action-setup@v4
with:
version: 7.x.x
version: 9.x.x
- name: Setup NodeJS
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '16'
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
Expand Down
19 changes: 8 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,21 @@ name: CI
jobs:
lint:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.9.1
with:
all_but_latest: true
access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: pnpm/action-setup@v2.2.2
- uses: pnpm/action-setup@v4
with:
version: 7.x.x
version: 9.x.x

- name: Setup NodeJS
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '16'
node-version: '20'
cache: 'pnpm'

- name: Install dependencies
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ A beautiful blogging platform for the JankariTech peoples.
authorName: John Doe
authorAvatar: https://some.link.jpg (must be an image URL, **required**)
authorLink: https://github.com/John
createdAt: Oct 30, 2019 (must be in the format `MM dd, yyyy`, **required**)
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**)
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**)
tags: vue, jest, unit, testing (separate multiple items with a comma `,` character, **required**)
banner: https://some.link.jpg (must be an image URL, **required**)
seriesTitle: Unit Testing is Fun (if only this post belongs to a series, **optional**)
Expand Down
24 changes: 21 additions & 3 deletions lint/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const requiredMeta = [
]

const optionalMeta = [
"updatedAt",
"seriesTitle",
"episode"
]
Expand Down Expand Up @@ -91,11 +92,28 @@ function lintMeta (key) {
})

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

if (!regex.test(peekData.createdAt)) {
log.error(`Invalid date format in ${key}`)
if (peekData.updatedAt) {
const updatedAt = new Date(peekData.updatedAt)
// check if the updatedAt is set with proper format
if (isNaN(updatedAt.getTime())) {
log.error(`Invalid updatedAt date format in ${key}`)
success = false
}
// check if the updatedAt is later than createdAt
if (createdAt.getTime() === updatedAt.getTime()) {
log.error(`Updated date is same as created date in ${key}`)
success = false
} else if (createdAt.getTime() > updatedAt.getTime()) {
log.error(`Updated date is earlier than created date in ${key}`)
success = false
}
}
Expand Down
Loading

0 comments on commit eb8c91d

Please sign in to comment.