Skip to content

Commit

Permalink
fix(git-changelog): initial dev commits not handled
Browse files Browse the repository at this point in the history
Signed-off-by: Neko Ayaka <[email protected]>
  • Loading branch information
nekomeowww committed Jul 6, 2024
1 parent bed4f72 commit 2c5feaa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
16 changes: 16 additions & 0 deletions packages/unconfig-vitepress/src/plugins/nolebase/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ const defaultOptions: NolebasePluginPresetOptions = {
enable: true,
options: {
mapContributors: [],
locales: {
'ru-RU': {
changelog: {
title: 'История изменений',
noData: 'Нет изменений',
lastEdited: 'Последнее редактирование: {{daysAgo}}',
lastEditedDateFnsLocaleName: 'ru',
viewFullHistory: 'Показать историю',
committedOn: ' от {{date}}',
},
contributors: {
title: 'Авторы',
noData: 'Нет информации',
},
},
},
},
},
graphView: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, inject, onMounted, ref } from 'vue'
import { computed, inject, onMounted, ref, watch } from 'vue'
import { differenceInDays, toDate } from 'date-fns'
import { useData } from 'vitepress'
import { defu } from 'defu'
Expand All @@ -26,7 +26,7 @@ const { lang, page } = useData()
const { t } = useI18n()
const { commits, update } = useCommits(page)
const lastChangeDate = ref<Date>(toDate(commits.value[0]?.date_timestamp))
const lastChangeDate = ref<Date>(commits.value[0]?.date_timestamp ? toDate(commits.value[0]?.date_timestamp) : new Date())
onMounted(() => {
if (import.meta.hot) {
Expand Down Expand Up @@ -63,7 +63,11 @@ onMounted(() => {
})
onMounted(() => {
lastChangeDate.value = toDate(commits.value[0]?.date_timestamp)
lastChangeDate.value = commits.value[0]?.date_timestamp ? toDate(commits.value[0]?.date_timestamp) : new Date()
})
watch(commits, () => {
lastChangeDate.value = commits.value[0]?.date_timestamp ? toDate(commits.value[0]?.date_timestamp) : new Date()
})
const locale = computed<Locale>(() => {
Expand All @@ -90,9 +94,9 @@ const reversedCommits = computed(() => {
</script>

<template>
<h2 :id="t('changelog.titleId')">
<h2 :id="t('changelog.titleId') || t('changelog.title')">
{{ t('changelog.title') }}
<a class="header-anchor" :href="`#${t('changelog.titleId')}`" :aria-label="`Permalink to '${t('changelog.title')}'`" />
<a class="header-anchor" :href="`#${t('changelog.titleId') || t('changelog.title')}`" :aria-label="`Permalink to '${t('changelog.title')}'`" />
</h2>
<em v-if="!commits.length" opacity="70">{{ t('noLogs', { omitEmpty: true }) || t('changelog.noData') }}</em>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ watch(commits, async (newCommits) => {
</script>

<template>
<h2 :id="t('contributors.titleId')">
<h2 :id="t('contributors.titleId') || t('contributors.title')">
{{ t('contributors.title') }}
<a class="header-anchor" :href="`#${t('contributors.titleId')}`" :aria-label="`Permalink to '${t('contributors.title')}'`" />
<a class="header-anchor" :href="`#${t('contributors.titleId') || t('contributors.title')}`" :aria-label="`Permalink to '${t('contributors.title')}'`" />
</h2>
<div
class="vp-nolebase-git-changelog vp-nolebase-git-changelog-contributors vp-nolebase-git-changelog-contributors-container vp-nolebase-git-changelog-contributors-list"
Expand Down

0 comments on commit 2c5feaa

Please sign in to comment.