Is it possible to have a dynamic url prefix? #335
-
Our site has multiple versions of the same docs, and the most recent version gets the url alias |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @jkrumbiegel! Thanks for writing in. I think you have two options. You could either change your url_prefix so that it references the If you were to go that second route, it might look something like setting your config's URL prefix to something like: [input]
url_prefix = "https://my-cool-docs-site.net/{VERSION}/" and then, when you register Stork on the page: const currentVersion = "v2.5.1"; // exported from build system
stork.register("search-index", "https://https://my-cool-docs-site.net/index.st", {
transformResultUrl: (url) => url.replaceAll("{VERSION}", currentVersion)
}); (I'm not a compiler, not 100% sure that that's valid code 😃) With that system in place, the links in the Stork dropdown will be of the form Let me know if that helps or if I'm missing something! -James |
Beta Was this translation helpful? Give feedback.
Hi @jkrumbiegel! Thanks for writing in.
I think you have two options. You could either change your url_prefix so that it references the
/stable/
urls, or you can use thetransformResultUrl
JS API to rewrite the URLs from some template string to your version string.If you were to go that second route, it might look something like setting your config's URL prefix to something like:
and then, when you register Stork on the page: