Skip to content
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

test versioning #38

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

test versioning #38

wants to merge 4 commits into from

Conversation

lazarusA
Copy link
Collaborator

test button

Comment on lines +11 to +12
// const dataHost = 'https://github.com/LuxDL/DocumenterVitepress.jl/blob/gh-pages/'
// const dataUrl = `${dataHost}/versions.js`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use this instead?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way it's synced with versions.jsfor all items. See e.g. https://geo.makie.org/versions.js

Copy link
Collaborator Author

@lazarusA lazarusA Feb 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄 , how? the issue is getting that list automatically? maybe from the Julia side then, read, parse and include? no idea.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could get the list by e.g.:

const dataHost = 'https://luxdl.github.io/DocumenterVitepress.jl'
const dataUrl = `${dataHost}/versions.js`

see e.g. https://luxdl.github.io/DocumenterVitepress.jl/versions.js

but I'm not sure how the list would be constructed - or how it should be structured!

Copy link
Collaborator Author

@lazarusA lazarusA Feb 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the template:

versions = [
  {text: 'stable', link: '/v0.0.3/',},
  {text: 'dev', link: '/dev/',},
  {text: 'v0.0.3', link: '/v0.0.3/'}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just remembered that I once added some version support for the mkdocs build (via mike), where I hooked into Documenter.HTMLWriter.generate_version_file: https://github.com/thofma/Hecke.jl/blob/master/docs/make.jl#L26-L52. I don't know where that list comes from, but it seemed to work well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could work as a first pass. My issue with it is that it creates a static version selector, meaning that people on docs of v0.4 could not access v0.6 through the selector.

If possible, the best thing to do is probably to somehow access versions.js in the browser and generate a selector on the client side...

@@ -39,10 +40,12 @@ export default defineConfig({
{ text: 'Getting Started', link: '/getting_started' },
{ text: 'Markdown', link: '/markdown-examples' },
{ text: 'Code', link: '/code_example' },
{ text: 'API', link: '/api' }
{ text: 'API', link: '/api' },
{ text: 'versions',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ text: 'versions',
{ text: 'REPLACE_ME_DOCUMENTER_VITEPRESS',

and then we add the current version (be it dev, preview, or v*) to it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm... note that the items part is the thing that needs to be replaced.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought you had some code in the component to make items dynamic?

@asinghvi17
Copy link
Collaborator

Code can be run client-side by wrapping it in a client-only div as in https://vitepress.dev/reference/runtime-api#clientonly

@asinghvi17
Copy link
Collaborator

I finally figured out how Documenter does this - it injects into <head> a script src="../siteinfo.js", so that the doc versions are loaded then and there.

https://github.com/JuliaDocs/Documenter.jl/blob/4fe9cf1237293c530633bcf0ef183b48417f23d7/src/html/HTMLWriter.jl#L999

So at least we know what they do. We could probably build a Vue component from this, I think.

@asinghvi17
Copy link
Collaborator

asinghvi17 commented May 17, 2024

We could include the Documenter version JS as a local script, then deploy a version selector based on that...probably wrapped in a ClientOnly block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants