Show page contributors from git history, linked to Gitea

This commit is contained in:
Djeex
2026-08-30 17:01:34 +02:00
parent ab8671e0fb
commit 630e8b9c84
3 changed files with 62 additions and 0 deletions
+36
View File
@@ -82,6 +82,23 @@ const editLink = computed(() => {
].filter(Boolean).join('/')
})
const contributors = computed(() => (page.value as unknown as Record<string, unknown>)?.contributors as string[] | undefined)
const historyLink = computed(() => {
if (!giteaUrl.value) {
return
}
return [
giteaUrl.value,
'commits',
'branch',
'main',
'content',
`${page.value?.stem}.${page.value?.extension}`,
].filter(Boolean).join('/')
})
// Add the page path to the prerender list
addPrerenderPath(`/raw${route.path}.md`)
</script>
@@ -149,6 +166,25 @@ addPrerenderPath(`/raw${route.path}.md`)
</template>
</div>
</USeparator>
<div
v-if="contributors?.length"
class="flex items-center gap-2 text-sm text-muted"
>
<UIcon
name="i-lucide-users"
class="size-4 shrink-0"
/>
<span>{{ locale === 'fr' ? (contributors.length > 1 ? 'Contributeurs' : 'Contributeur') : (contributors.length > 1 ? 'Contributors' : 'Contributor') }}:</span>
<ULink
v-if="historyLink"
:to="historyLink"
target="_blank"
class="text-highlighted hover:underline"
>
{{ contributors.join(', ') }}
</ULink>
<span v-else>{{ contributors.join(', ') }}</span>
</div>
<UContentSurround :surround="surround" />
</UPageBody>