traefik / structor

[Messor Structor 🐜] Manage multiple versions of a Mkdocs documentation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Version selection loading the new content

adibrastegarnia opened this issue Β· comments

I have a question about the code. I am trying to understand when we click on a version how does it load the generated website for that specific version? I looked at the menu package but it looks like it just updates the menu but I don't know how it loads the generated website (How does it update the navigation links) for that specific version . Would you please give me some pointers?

Structor generates the following files structure:

. (latest, branch v1.2)
β”œβ”€β”€ ...
β”œβ”€β”€ index.html
β”œβ”€β”€ v1.0 (branch v1.0)
β”‚   β”œβ”€β”€ ...
β”‚   └── index.html
β”œβ”€β”€ v1.1 (branch v1.1)
β”‚   β”œβ”€β”€ ...
β”‚   └── index.html
└── v1.2 (branch v1.2)
    β”œβ”€β”€ ...
    └── index.html

So if you serve the content from . to mydoc.com

  • mydoc.com (latest, branch v1.2)
  • mydoc.com/v1.0 (branch v1.0)
  • mydoc.com/v1.1 (branch v1.1)
  • mydoc.com/v1.2 (branch v1.2)

The "loading" is just a click on a simple HTML anchor.
https://github.com/containous/structor/blob/7352c07ef4e6581e078daa2259fceeda2123bc0e/traefik-menu.js.gotmpl#L64-L76

Thanks for your response and the pointer.

@ldez
Sorry for my lots of questions. I am trying to reproduce almost the same thing locally except I use tags instead of branches. A couple of things that are not clear for me yet:

1- Do we need to build each version using the modified version of mkdocs.yml file (i.e. the version which contains path to the menu js file (extra_javascript))? If that is the case how the navigation will get updated? I don't see any change in the navigation of mkdocs.yml file

2- I can build the website for each version without any problems but when I select one of them, it doesn't reload it because it always use the mkdocs.yml file in the root which points to the latest version.I tried to build your site locally to see how it works but it looks like it doesn't work for local testing (i.e. it doesn't show any version selector).

The branches are a requirement, Structor doesn't follow tags.

Structor modifies the mkdocs.yml file during the build, so you don't need to do that manually.

To use structor you don't need to adapt your mkdocs.yml, but you need to create a traefik-menu.js.gotmpl to generate the menu related to your theme.