Skip to content

Commit 39bafe9

Browse files
hywaxbenjamincanac
andauthored
docs(components): add changelog commit history (#4601)
Co-authored-by: Benjamin Canac <[email protected]>
1 parent 9d41d55 commit 39bafe9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+339
-0
lines changed

cli/templates.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ navigation.badge: Soon
213213
## Theme
214214
215215
:component-theme${pro ? '{pro}' : ''}
216+
217+
## Changelog
218+
219+
:component-changelog
216220
`
217221
}
218222
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<script setup lang="ts">
2+
import type { CommitInfo } from '#build/changelog'
3+
import { camelCase } from 'scule'
4+
import { changelog } from '#build/changelog'
5+
6+
const route = useRoute()
7+
const camelName = camelCase((route.path.split('/').pop() ?? '').replace(/-/g, ''))
8+
9+
const commits = computed(() => {
10+
const related = changelog.filter(c => c.version || c.components?.some(i => i.includes(camelName)))
11+
return related.filter((i, idx) => !(i.version && (!related[idx + 1] || related[idx + 1]?.version)))
12+
})
13+
14+
function normalizeCommitMessage(commit: CommitInfo) {
15+
const prefix = `[\`${commit.hash.slice(0, 5)}\`](https://github.com/nuxt/ui/commit/${commit.hash})`
16+
const content = commit.message.replace(/\(.*?\)/, '')
17+
.replace(/#(\d+)/g, '<a href=\'https://github.com/nuxt/ui/issues/$1\'>#$1</a>')
18+
.replace(/`(.*?)`/g, '<code class="text-xs">$1</code>')
19+
20+
return `${prefix} — ${content}`
21+
}
22+
</script>
23+
24+
<template>
25+
<div v-if="!commits.length">
26+
No recent changes
27+
</div>
28+
29+
<div class="flex flex-col gap-1.5 relative">
30+
<div class="bg-accented w-px h-full absolute left-[11px] z-[-1]" />
31+
32+
<template v-for="(commit, idx) of commits" :key="commit.hash">
33+
<div v-if="idx === 0 && !commit.version" class="flex gap-1.5 items-center">
34+
<UAvatar icon="i-lucide-git-pull-request-draft" size="xs" class="shrink-0 ring-2 ring-bg" />
35+
<div class="text-muted text-sm/5">
36+
Pending for release...
37+
</div>
38+
</div>
39+
40+
<div v-if="commit.version" class="flex gap-1.5 items-center">
41+
<UAvatar icon="i-lucide-rocket" size="xs" class="shrink-0 ring-2 ring-bg" />
42+
<div class="text-sm">
43+
<ProseA :href="`https://github.com/nuxt/ui/releases/tag/${commit.version}`" target="_blank">
44+
{{ commit.version }}
45+
</ProseA>
46+
<span class="text-muted text-xs/5"> on <NuxtTime :datetime="commit.date" /></span>
47+
</div>
48+
</div>
49+
<div v-else class="flex gap-1.5 items-center">
50+
<div class="bg-accented ring-2 ring-bg size-1.5 mx-[8.5px] rounded-full" />
51+
<MDC :value="normalizeCommitMessage(commit)" class="text-sm [&>*]:py-0 [&>*]:my-0 [&_code]:text-xs" tag="div" />
52+
</div>
53+
</template>
54+
</div>
55+
</template>

docs/content/3.components/accordion.md

Lines changed: 4 additions & 0 deletions

docs/content/3.components/alert.md

Lines changed: 4 additions & 0 deletions

docs/content/3.components/avatar-group.md

Lines changed: 4 additions & 0 deletions

docs/content/3.components/avatar.md

Lines changed: 4 additions & 0 deletions

docs/content/3.components/badge.md

Lines changed: 4 additions & 0 deletions

docs/content/3.components/breadcrumb.md

Lines changed: 4 additions & 0 deletions

docs/content/3.components/button-group.md

Lines changed: 4 additions & 0 deletions

docs/content/3.components/button.md

Lines changed: 4 additions & 0 deletions

0 commit comments

Comments
 (0)