My inquiry is about lunr search implementation, I googled everywhere (jekyll users have similar questions) - and could not find an advice. The problem is to generate a relative link to the index file.
I’m using doc dock theme for a documentation site which users will open from the file system. and the problem is that search.js can not pick the index.json.
Here’s how the variable is defined for search.js to pick the index.json:
var baseurl = “{{.Site.BaseURL}}”
I’m having relative links on in the config file:
relativeURLs = true
My expected result is that the base url variable will contain relative path from my context to the publish directory. The actual result is that it pastes what I have in the baseURL (in my config it is set to “/”) without computing the relative path:
var baseurl = “/”;
I guess this is because baseurl variable is inside tag?
I posted an example of repository which reproduces this case:
Please advise if there’s a trick I an use to make search work with site running from disk?
Imagine, the site is on disk im folder /user/apo/dir1/di2/documentation/
Index file would be in the same folder.
If I walk to an html page in section ./features/editing/feature1.html I want on this page the var baseurl to be …/…/ - so that it points to the root as a relative link.
But I’m still not understanding your question. My understanding of Lunr JS is that it needs a single index file. And this single file can be referenced by any other page by using /index.json
/index.json means root. I need not global root, but root of site (where the user unzipped the site - I don’t know the path, hence need the link to be relative to current page, for instance …/…/index.json
I see your issue now. Sorry about that, I missed the part about it being served from local disk vs web server.
So like you mentioned, I’m curious why the relative link for that file isn’t being produced. Because your config file looks fine. And when viewing your publish folder, the other links are definitely relative. Hmm…