Rendering assets in mdBook #3835
-
After playing around with different ways of getting the assets rendered, I noticed a couple things. Turns out assets do in fact work the way it is currently structured. On the local server that mdBook launches, the assets will not be rendered as it is out of scope of the server. However, when deployed to GitHub pages they will render properly. The reason assets don't render locally is because However, since we deploy the entire Although that works when the mdBook projects are hosted with the required assets, the down side of this approach is that the assets will not render when locally hosted using the command that mdBook provides (as the server is restricted to the What Didn't WorkmdBook has support for custom preprocesses before building the book, allowing you to run your own commands before the book is built. Drasil has the knowledge of where the assets are located, and where they should be located in order to be rendered. The idea behind this approach is that each example's When the script was run manually, everything ran perfectly. However, when added to the Possible SolutionsHere are some ideas for possible approaches @balacij and I came up with. Script to create symbolic links inside
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Symbolic links AFAIK are not entirely portable. Launching our own server seems like overkill. So the second solution seems best. |
Beta Was this translation helpful? Give feedback.
-
I have developed two prototypes showcasing possible solutions for rendering assets in mdBook. One being the CSV approach that that we discussed in #3834. The other being a Makefile approach which leverages the features from #3841. CSV ApproachThis approach is prototyped in #3848. In this approach, a CSV file is generated by each example that maps the actual location of the assets (specified in Makefile ApproachThis approach is prototyped in #3847. From #3841, each generated mdBook project will also generate a makefile to both build the project and launch the server. Since we are already generating a makefile, we can easily add the copying of assets into this generated makefile, rather than going through the whole CSV and generic script ordeal. Since the paths to the assets are also relative to the location of the makefile, this removes the hassle of Combination of BothWe can also always do a combination both. We can generate both a CSV file and include the copying of assets in the generated makefiles. We will then have to decide which method to use in our main I personally like the Makefile approach. With the CSV approach, the generated makefiles will just build and launch the server without the assets. With the Makefile approach, copying over the assets will be a dependency for building and launching the server, ensuring assets are always rendered when locally hosted (if done through the generated makefile). |
Beta Was this translation helpful? Give feedback.
Symbolic links AFAIK are not entirely portable. Launching our own server seems like overkill. So the second solution seems best.