I am using Mirador 3 in the context of a static website built with Hugo.
When I embed Mirador from the unpkg URL, I can easily set different options on different pages (here using Hugo templating syntax to set the manifest):
<script src="https://unpkg.com/mirador@latest/dist/mirador.min.js"></script>
<div id="mirador"></div>
<script>
const mirador = Mirador.viewer({
id: "mirador",
windows: [
{
manifestId: '/manifests/{{ .Params.internalCatalogueID }}.json'
}
]
});
</script>
However, I need to use a few plugins, including the download plugin.
When I create a Mirador build with plug-ins, I don't have an obvious way to set different configuration options on different pages. The configuration options are stuck with whatever was set when the build was created.
I.e., something like this doesn't work:
<div id="demo"></div>
<script src="dist/main.js"></script>
<script>
const mirador = Mirador.viewer({
id: "demo",
windows: [
{
manifestId: '/manifests/{{ .Params.internalCatalogueID }}.json'
}
]
});
</script>
-> What's the best practice for setting Mirador configurations on different pages, when using a build with plug-ins?
Instead of hardcoding the parameters at build time, export a function from the bundle to the global namespace that sets up Mirador and that you can then pass your custom options to from outside of the bundle:
And then in your HTML: