rust-lang / rust-lang/mdBook

Allow additional javascript attributes in the configuration

Open
#2,444 1 comment 2 reactions 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.