-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
versioning, picker component #178
base: master
Are you sure you want to change the base?
Changes from 2 commits
2a49f32
8da1304
8685cc8
ad24a25
dcf271d
90d89e8
1c61302
da4fd3e
a30f7af
18ccaf7
dcc8919
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,21 @@ import mathjax3 from "markdown-it-mathjax3"; | |
import footnote from "markdown-it-footnote"; | ||
import { transformerMetaWordHighlight } from '@shikijs/transformers'; | ||
|
||
|
||
const baseTemp = { | ||
base: 'REPLACE_ME_DOCUMENTER_VITEPRESS',// TODO: replace this in makedocs! | ||
} | ||
|
||
const navTemp = { | ||
nav: 'REPLACE_ME_DOCUMENTER_VITEPRESS', | ||
} | ||
|
||
const nav = [ | ||
...navTemp.nav, | ||
{ | ||
component: 'VersionPicker' | ||
} | ||
] | ||
// https://vitepress.dev/reference/site-config | ||
export default defineConfig({ | ||
base: 'REPLACE_ME_DOCUMENTER_VITEPRESS', // TODO: replace this in makedocs! | ||
|
@@ -12,7 +27,11 @@ export default defineConfig({ | |
lastUpdated: true, | ||
cleanUrls: true, | ||
outDir: 'REPLACE_ME_DOCUMENTER_VITEPRESS', // This is required for MarkdownVitepress to work correctly... | ||
head: [['link', { rel: 'icon', href: '/DocumenterVitepress.jl/dev/favicon.ico' }]], | ||
head: [ | ||
['link', { rel: 'icon', href: '/DocumenterVitepress.jl/dev/favicon.ico' }], | ||
['script', {src: '/versions.js'}], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @asinghvi17 not here? I think I just need to add base here, isn't? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes that should also work! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, that doesn't work. It populates the menu, but the links are wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mmm, not sure how to propagate base to the Vue component. If I'm not too tired, I will check again later. It will be good to have this finally in the next release, which will be breaking either way. So, a big bump will also be needed. Someone that knows more about it, please commit the appropriate bump. |
||
['script', {src: `${baseTemp.base}siteinfo.js`}] | ||
], | ||
vite: { | ||
build: { | ||
assetsInlineLimit: 0, // so we can tell whether we have created inlined images or not, we don't let vite inline them | ||
|
@@ -43,7 +62,7 @@ export default defineConfig({ | |
detailedView: true | ||
} | ||
}, | ||
nav: 'REPLACE_ME_DOCUMENTER_VITEPRESS', | ||
nav, | ||
sidebar: 'REPLACE_ME_DOCUMENTER_VITEPRESS', | ||
editLink: 'REPLACE_ME_DOCUMENTER_VITEPRESS', | ||
socialLinks: [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<!-- From https://github.com/MakieOrg/Makie.jl/blob/master/docs/src/.vitepress/theme/VersionPicker.vue --> | ||
|
||
<script setup lang="ts"> | ||
import { computed, ref, onMounted } from 'vue' | ||
import { useRoute } from 'vitepress' | ||
import VPNavBarMenuGroup from 'vitepress/dist/client/theme-default/components/VPNavBarMenuGroup.vue' | ||
import VPNavScreenMenuGroup from 'vitepress/dist/client/theme-default/components/VPNavScreenMenuGroup.vue' | ||
|
||
const props = defineProps<{ | ||
screenMenu?: boolean | ||
}>() | ||
|
||
const route = useRoute() | ||
|
||
const versions = ref([]); | ||
const currentVersion = ref('Versions'); | ||
|
||
const waitForGlobalDocumenterVars = () => { | ||
return new Promise((resolve) => { | ||
const checkInterval = setInterval(() => { | ||
if (window.DOC_VERSIONS && window.DOCUMENTER_CURRENT_VERSION) { | ||
clearInterval(checkInterval); | ||
resolve({ | ||
versions: window.DOC_VERSIONS, | ||
currentVersion: window.DOCUMENTER_CURRENT_VERSION | ||
}); | ||
} | ||
}, 100); // Check every 100ms | ||
}); | ||
}; | ||
|
||
onMounted(async () => { | ||
const globalvars = await waitForGlobalDocumenterVars(); | ||
versions.value = globalvars.versions.map((v) => { | ||
return {text: v, link: `${window.location.origin}/${v}/`} | ||
}); | ||
currentVersion.value = globalvars.currentVersion; | ||
}); | ||
|
||
</script> | ||
|
||
<template> | ||
<VPNavBarMenuGroup | ||
v-if="!screenMenu" | ||
:item="{ text: currentVersion, items: versions }" | ||
class="VPVersionPicker" | ||
/> | ||
<VPNavScreenMenuGroup | ||
v-else | ||
:text="currentVersion" | ||
:items="versions" | ||
class="VPVersionPicker" | ||
/> | ||
</template> | ||
|
||
<style scoped> | ||
.VPVersionPicker :deep(button .text) { | ||
color: var(--vp-c-text-1) !important; | ||
} | ||
|
||
.VPVersionPicker:hover :deep(button .text) { | ||
color: var(--vp-c-text-2) !important; | ||
} | ||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asinghvi17 by the way, the way these strings are replaced makes the code unnecessarily ugly. Couldn't you give every bit its own name like
REPLACE_ME_DOCUMENTER_VITEPRESS_FAVICON
? Then one could it splice in directly wherever needed without relying on thebase:
thing being present.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, it's not super complicated to do either. Will look into it today.