Skip to content

Commit

Permalink
doc: add new version message
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed Jan 1, 2025
1 parent a28b4c4 commit d86cc2b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
44 changes: 44 additions & 0 deletions docs/.vitepress/components/VersionBanner.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<v-snackbar v-model="open" timeout="-1" max-width="none">
<span style="padding-right: 2em">
🎉 A new version has been released since you last visited this page: <strong>{{ latestVersion }}</strong>
</span>

<template v-slot:actions>
<v-btn size="small" variant="elevated" color="primary" @click="changelog()">Changelog</v-btn>
<v-btn size="small" variant="text" icon="mdi-close-circle" aria-label="Close" @click="close()"></v-btn>
</template>
</v-snackbar>
</template>

<script setup lang="ts">
import { useRouter } from 'vitepress';
import { onMounted, ref } from 'vue';
const router = useRouter();
const latestVersion = ref(null);
const open = ref(false);
onMounted(async () => {
const response = await fetch('https://registry.npmjs.org/@photo-sphere-viewer%2Fcore');
if (response.ok) {
const data = await response.json();
latestVersion.value = data['dist-tags']['latest'];
if (!localStorage.version && localStorage.announcementsCache) {
localStorage.version = latestVersion.value;
} else if (latestVersion.value !== localStorage.version) {
open.value = true;
}
}
});
function changelog() {
close();
router.go('/guide/changelog');
}
function close() {
localStorage.version = latestVersion.value;
open.value = false;
}
</script>
8 changes: 6 additions & 2 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
VRow,
VSelect,
VSlider,
VSnackbar,
VTab,
VTabs,
VTabsWindow,
Expand All @@ -39,6 +40,7 @@ import ApiButton from '../components/ApiButton.vue';
import Badges from '../components/Badges.vue';
import HomeBackground from '../components/HomeBackground.vue';
import ThemeProvider from '../components/ThemeProvider.vue';
import VersionBanner from '../components/VersionBanner.vue';
import codeDemo from '../plugins/code-demo/enhanceApp';
import dialog from '../plugins/dialog/enhanceApp';
import gallery from '../plugins/gallery/enhanceApp';
Expand All @@ -64,10 +66,11 @@ const vuetify = createVuetify({
VIcon,
VMenu,
VNumberInput,
VRow,
VSlider,
VRangeSlider,
VRow,
VSelect,
VSlider,
VSnackbar,
VTab,
VTabs,
VTabsWindow,
Expand Down Expand Up @@ -140,6 +143,7 @@ export default {
return h(ThemeProvider, h(DefaultTheme.Layout, null, {
'home-hero-before': () => h(HomeBackground),
'home-features-after': () => h(Announcements),
'layout-bottom': () => h(VersionBanner),
}));
},
enhanceApp({ app }) {
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lint": "eslint . --fix",
"serve-doc": "vitepress dev"
},
"dependencies": {
"devDependencies": {
"lodash-es": "^4.17.21",
"markdown-it-container": "^4.0.0",
"vitepress": "^1.5.0",
Expand Down

0 comments on commit d86cc2b

Please sign in to comment.