statistics: Better display on the front page

This commit is contained in:
Tom Wiesing 2022-11-16 19:51:17 +01:00
parent bc1bf0db1c
commit 9a1cf4e53b
No known key found for this signature in database
12 changed files with 181 additions and 59 deletions

View file

@ -1,7 +1,17 @@
import dayjs from "dayjs"
const types: Record<string, (element: HTMLElement) => HTMLElement | string> = {
"date": (element) => {
return dayjs(element.innerText).format('YYYY-MM-DD HH:mm:ss ([UTC]Z)')
const value = dayjs(element.innerText);
const text = value.format('YYYY-MM-DD HH:mm:ss ([UTC]Z)')
// if the date is the zero date, then it is assumed to be invalid
if (value.unix() === 0) {
const code = document.createElement('code')
code.style.color = 'gray'
code.append(text)
return code
}
return text
},
"path": (element) => {
const text = element.innerText.split("/");