Allow additional javascript attributes in the configuration
Open
@h7kanna is already working on this.
Since Oct 8, 2024.
C-enhancement
- Dominant language
- Rust
- Stars
- 22.2k
- Forks
- 1.9k
- PR merge metrics
- PR metrics pending
Description
Problem
I am not able to include a JavaScript module in the additional_js option.
Example:
<!-- Custom JS scripts -->
<script src="custom-js/index.js" type="module" async></script>
Currently, the configuration is only a list of file name strings.
Also the custom head.hbs cannot be used as additional_js is only for local files.
Proposed Solution
Provide new additional-js-attributes option augmenting the existing additional-js option.
Example:
[output.html]
additional-js = ["custom-js/index.js", "custom-js/xtermjs"]
additional-js-attributes = [
[
{ type = "module" },
{ async = true },
],
[
{ type = "module" },
{ async = true },
],
]
Notes
Demo implementation is here https://github.com/rust-lang/mdBook/compare/master...h7kanna:mdBook:additional-js-attributes
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.