1
0
mirror of https://github.com/badges/shields.git synced 2025-07-07 07:01:09 +03:00

Add renderDateBadge helper; affects [aur BitbucketLastCommit chrome date eclipse factorio galaxytoolshed GiteaLastCommit GistLastCommit GithubCreatedAt GithubHacktoberfest GithubIssueDetail GithubLastCommit GithubReleaseDate GitlabLastCommit maven npm openvsx snapcraft SourceforgeLastCommit steam vaadin visualstudio wordpress] (#10682)

* add and consistently use parseDate and renderDateBadge helpers

also move

- age
- formatDate
- formatRelativeDate

to date.js

* fix bug in wordpress last update badge

* validate in formatDate() and age()

it is going to be unlikely we'll invoke either of these
directly now, but lets calidate here too

* remove unusued imports

* reverse colours for galaxy toolshed
This commit is contained in:
chris48s
2024-11-17 13:15:28 +00:00
committed by GitHub
parent 4132ca2e7e
commit 5cdef88bcc
32 changed files with 323 additions and 457 deletions

View File

@ -1,7 +1,6 @@
import Joi from 'joi'
import { pathParams } from '../../index.js'
import { formatDate } from '../../text-formatters.js'
import { age as ageColor } from '../../color-formatters.js'
import { renderDateBadge } from '../../date.js'
import { GithubAuthV3Service } from '../github-auth-service.js'
import { documentation, httpErrorsFor } from '../github-helpers.js'
@ -27,13 +26,6 @@ export default class GistLastCommit extends GithubAuthV3Service {
static defaultBadgeData = { label: 'last commit' }
static render({ commitDate }) {
return {
message: formatDate(commitDate),
color: ageColor(Date.parse(commitDate)),
}
}
async fetch({ gistId }) {
return this._requestJson({
url: `/gists/${gistId}`,
@ -44,6 +36,6 @@ export default class GistLastCommit extends GithubAuthV3Service {
async handle({ gistId }) {
const { updated_at: commitDate } = await this.fetch({ gistId })
return this.constructor.render({ commitDate })
return renderDateBadge(commitDate)
}
}