fix: refine anchor extraction and changelog dates

This commit is contained in:
Justineo 2022-01-19 14:21:05 +08:00
parent 67ab3454ef
commit 9f5d731b68
No known key found for this signature in database
GPG Key ID: B73F0979CF18A0EA
3 changed files with 26 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import visit from 'unist-util-visit'
import { upperFirst } from './util'
const KNOWN_SCOPES_CONFIG = {
props: '属性',
@ -13,7 +14,7 @@ const KNOWN_SCOPES_CONFIG = {
}
const KNOWN_SCOPES = Object.entries(KNOWN_SCOPES_CONFIG).reduce(
(acc, [key, value]) => {
acc[key] = key
acc[upperFirst(key)] = key
acc[value] = key
return acc
},

View File

@ -27,3 +27,10 @@ export function hash (path) {
hash.update(path)
return hash.digest('hex').substring(0, 7)
}
export function upperFirst (str) {
if (str.length === 0) {
return str
}
return str[0].toUpperCase() + str.slice(1)
}

View File

@ -90,7 +90,10 @@
<nuxt-link
:to="`#${getHash(version)}`"
>
{{ version }}<small v-if="codeName">{{ codeName }}</small><small v-if="date">{{ date }}</small>
{{ version }}<small v-if="codeName">{{ codeName }}</small><time
v-if="date"
:datetime="date"
>{{ date }}</time>
</nuxt-link>
</h2>
<ul class="changeset">
@ -300,8 +303,11 @@ h2
color #333 !important
small
time
display inline-flex
align-items center
small
font-size 14px
&::before
@ -309,6 +315,16 @@ h2
font-size 20px
margin 0 8px
time
font-size 12px
color #999
&::before
content "/"
font-size 10px
margin 0 8px
color #ccc
.changeset
list-style-type none
padding-left 0