diff --git a/docs/.vitepress/activity.data.ts b/docs/.vitepress/activity.data.ts index 54b04bec..7778729d 100644 --- a/docs/.vitepress/activity.data.ts +++ b/docs/.vitepress/activity.data.ts @@ -1,6 +1,26 @@ -declare const data: { stars: number; pulls: number }; +declare const data: { + stars: number; + pulls: number; + contributors: number; + release: { version: string; date: string } | null; +}; export { data }; +// The contributors endpoint has no total count, so ask for one per page and read +// the last page number out of the Link header. +async function fetchContributorCount() { + const res = await fetch("https://api.github.com/repos/amir20/dozzle/contributors?per_page=1&anon=false"); + const match = res.headers.get("link")?.match(/[?&]page=(\d+)>; rel="last"/); + return match ? parseInt(match[1], 10) : 0; +} + +async function fetchLatestRelease() { + const res = await fetch("https://api.github.com/repos/amir20/dozzle/releases/latest"); + const json = await res.json(); + if (!json.tag_name) return null; + return { version: json.tag_name, date: json.published_at }; +} + export default { async load() { const urls = [ @@ -8,13 +28,18 @@ export default { "https://hub.docker.com/v2/namespaces/amir20/repositories/dozzle", ]; - const responses = await Promise.all(urls.map((url) => fetch(url).then((res) => res.json()))); + const [repo, hub, contributors, release] = await Promise.all([ + ...urls.map((url) => fetch(url).then((res) => res.json())), + // Never fail the build over a rate-limited or flaky API call. + fetchContributorCount().catch(() => 0), + fetchLatestRelease().catch(() => null), + ]); - const data = { - stars: responses[0].stargazers_count, - pulls: responses[1].pull_count, + return { + stars: repo.stargazers_count, + pulls: hub.pull_count, + contributors, + release, }; - - return data; }, }; diff --git a/docs/.vitepress/theme/components/FinalCta.vue b/docs/.vitepress/theme/components/FinalCta.vue new file mode 100644 index 00000000..26527177 --- /dev/null +++ b/docs/.vitepress/theme/components/FinalCta.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/docs/.vitepress/theme/components/HeroTrust.vue b/docs/.vitepress/theme/components/HeroTrust.vue new file mode 100644 index 00000000..3b95952b --- /dev/null +++ b/docs/.vitepress/theme/components/HeroTrust.vue @@ -0,0 +1,42 @@ + + + diff --git a/docs/.vitepress/theme/components/InstallCommand.vue b/docs/.vitepress/theme/components/InstallCommand.vue index 3a092b80..2caeeee3 100644 --- a/docs/.vitepress/theme/components/InstallCommand.vue +++ b/docs/.vitepress/theme/components/InstallCommand.vue @@ -2,6 +2,11 @@ import { useClipboard } from "@vueuse/core"; import { withBase } from "vitepress"; +const { hint = true, dense = false } = defineProps<{ + hint?: boolean; + dense?: boolean; +}>(); + const command = "docker run -d -v /var/run/docker.sock:/var/run/docker.sock -v dozzle_data:/data -p 8080:8080 amir20/dozzle:latest"; @@ -9,7 +14,7 @@ const { copy, copied } = useClipboard({ source: command, copiedDuring: 2000 });