mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
feat: add GitHub stars button to docs navbar and fix footer license
Add a star button with live count from the GitHub API in the top-right of the docs site. Fix footer from "MIT License" to "AGPLv3 License".
This commit is contained in:
@@ -53,7 +53,7 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
|
|
||||||
footer: {
|
footer: {
|
||||||
message: "Released under the MIT License.",
|
message: 'Released under the <a href="https://github.com/stirling-image/stirling-image/blob/main/LICENSE">AGPLv3 License</a>.',
|
||||||
copyright:
|
copyright:
|
||||||
'AI-friendly docs available at <a href="/stirling-image/llms.txt">/llms.txt</a> · <a href="/stirling-image/llms-full.txt">/llms-full.txt</a>',
|
'AI-friendly docs available at <a href="/stirling-image/llms.txt">/llms.txt</a> · <a href="/stirling-image/llms-full.txt">/llms-full.txt</a>',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, onMounted } from "vue";
|
||||||
|
|
||||||
|
const stars = ref<string | null>(null);
|
||||||
|
const repo = "https://github.com/stirling-image/stirling-image";
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
try {
|
||||||
|
const res = await fetch("https://api.github.com/repos/stirling-image/stirling-image");
|
||||||
|
if (!res.ok) return;
|
||||||
|
const data = await res.json();
|
||||||
|
const count = data.stargazers_count;
|
||||||
|
stars.value = count >= 1000 ? `${(count / 1000).toFixed(1)}k` : String(count);
|
||||||
|
} catch {
|
||||||
|
// Silently fail - stars badge just won't show a count
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="github-stars-wrapper">
|
||||||
|
<a :href="repo" target="_blank" rel="noopener" class="github-stars-btn">
|
||||||
|
<svg
|
||||||
|
width="16"
|
||||||
|
height="16"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
fill="currentColor"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.75.75 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<span>Star</span>
|
||||||
|
</a>
|
||||||
|
<a
|
||||||
|
v-if="stars !== null"
|
||||||
|
:href="`${repo}/stargazers`"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener"
|
||||||
|
class="github-stars-count"
|
||||||
|
>
|
||||||
|
{{ stars }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<script setup>
|
||||||
|
import DefaultTheme from "vitepress/theme";
|
||||||
|
import GitHubStars from "./GitHubStars.vue";
|
||||||
|
|
||||||
|
const { Layout } = DefaultTheme;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Layout>
|
||||||
|
<template #nav-bar-content-after>
|
||||||
|
<GitHubStars />
|
||||||
|
</template>
|
||||||
|
</Layout>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
.github-stars-wrapper {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-left: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.github-stars-btn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 4px 12px;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 20px;
|
||||||
|
color: var(--vp-c-text-1);
|
||||||
|
background: var(--vp-c-bg-soft);
|
||||||
|
border: 1px solid var(--vp-c-divider);
|
||||||
|
border-radius: 6px 0 0 6px;
|
||||||
|
text-decoration: none;
|
||||||
|
transition: background 0.2s, border-color 0.2s;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.github-stars-btn:hover {
|
||||||
|
background: var(--vp-c-bg-mute);
|
||||||
|
border-color: var(--vp-c-text-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.github-stars-btn svg {
|
||||||
|
color: var(--vp-c-yellow-2, #d4a72c);
|
||||||
|
}
|
||||||
|
|
||||||
|
.github-stars-count {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 4px 10px;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 20px;
|
||||||
|
color: var(--vp-c-text-2);
|
||||||
|
background: var(--vp-c-bg);
|
||||||
|
border: 1px solid var(--vp-c-divider);
|
||||||
|
border-left: none;
|
||||||
|
border-radius: 0 6px 6px 0;
|
||||||
|
text-decoration: none;
|
||||||
|
transition: color 0.2s, border-color 0.2s;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.github-stars-count:hover {
|
||||||
|
color: var(--vp-c-brand-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* When there's no count yet, round all corners on the button */
|
||||||
|
.github-stars-btn:only-child {
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hide on very small screens to avoid crowding */
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.github-stars-wrapper {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import DefaultTheme from "vitepress/theme";
|
||||||
|
import Layout from "./Layout.vue";
|
||||||
|
import "./github-stars.css";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
extends: DefaultTheme,
|
||||||
|
Layout,
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user