structor icon indicating copy to clipboard operation
structor copied to clipboard

Version selection loading the new content

Open adibrastegarnia opened this issue 6 years ago • 4 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?

adibrastegarnia avatar Oct 19 '19 22:10 adibrastegarnia

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

ldez avatar Oct 20 '19 00:10 ldez

Thanks for your response and the pointer.

adibrastegarnia avatar Oct 20 '19 03:10 adibrastegarnia

@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).

adibrastegarnia avatar Oct 20 '19 19:10 adibrastegarnia

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.

ldez avatar Oct 20 '19 21:10 ldez