Closed HugoGranstrom closed 3 years ago
Well in principle you could run nbook dump
and have book.json. Or maybe there is a way to reintroduce the mechanism that recreated book.json in case missing (was removed while removing dependency from nimble: https://github.com/pietroppeter/nimibook/commit/5ce2987b679c32b1a3b46ffc1522fd90927b60be#diff-088ca8b1930728fc51159ac7a84d1843415f37b9eb8d0769eb8c4fa60e0998d8L28). Third option could be to load an empty json if the file is not there (you would not see the Toc). A compile time switch to disable nimibook is also I think a good thing to introduce since you might want to check if an issue is due to nimibook or if it is still there in "plain" nimib.
Well in principle you could run nbook dump and have book.json. Or maybe there is a way to reintroduce the mechanism that recreated book.json in case missing (was removed while removing dependency from nimble.
Having to do it manually and having to redo it after every time nbook build
is run (cleans it) doesn't sound ideal for the user. And even harder for NimiBoost to handle if it is to be done automatically. As the homeDir could be virtually everywhere it sounds hard to be able to locate the nimble file/nbook binary in the recreation way you linked.
Third option could be to load an empty json if the file is not there (you would not see the Toc). A compile time switch to disable nimibook is also I think a good thing to introduce since you might want to check if an issue is due to nimibook or if it is still there in "plain" nimib.
Empty json could work although the TOC wouldn't work either way as the relative paths to all the other files wouldn't be valid in the temp dir I put it. That's why I thought I could as well just throw away everything Nimibook related to not have to deal with all that. If the compile-time switch can have dual purposes then that would be really nice 😄 the last thing I want is to have Nimib and Nimibook include a bunch of workarounds that are only ever used in NimiBoost 🤣
Have you felt any pull towards the skipNimibook
lately? 😛 I'm going to try the empty book.json
file for now and see if I can get it working :)
thinking back to this, I think the easiest way would be to change the line you reported above to have an empty json if the file does not exist (it should probably emit a warning in that case).
Sounds like a good idea 👍 I can confirm that the solution of creating a book.json
with the content {}
works for Nimiboost!
change the line you reported above to have an empty json if the file does not exist
Does we even have to create the empty file? If it doesn't already exist we could just return an empty Book
object, right?
Ah yes that is what I meant
I can open a PR for this as well while I'm at it and then NimiBoost should be ready for release :)
When trying to get individual pages of a NimiBook to run in preview mode in NimiBoost I stumbled upon this problem: here in
useNimibook
it loadsbook.json
which doesn't unless run using the publishing mechanics of NimiBook's CLI. It is on top of that removed after generating the book so reusing it after a first run isn't possible either: https://github.com/pietroppeter/nimibook/blob/2e2d2ec2c39e2a0fcc6b3fa580ed0caff4939476/src/nimibook/publishers.nim#L40The idea of the preview mode is to focus on the content more than the layout so it doesn't really need any NimiBook functionality to run at all. It can just show every page as the default Nimib theme. So for me yet another commandline switch to disable all NimiBook functionality would work for me (I think). It's just a matter of inserting a
when not defined(skipNimibook)
in nbUseNimibook.What do you think? Is there another way to do it?