Skip to content

Commit

Permalink
Added support for using .mjs files in extra_javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed May 30, 2023
1 parent e8c4528 commit 530f844
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"items": {
"title": "Path to JavaScript file",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/customization/#additional-javascript",
"pattern": "\\.js($|\\?)"
"pattern": "\\.m?js($|\\?)"
},
"uniqueItems": true,
"minItems": 1
Expand Down
6 changes: 5 additions & 1 deletion material/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,11 @@
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.b4d07000.min.js' | url }}"></script>
{% for path in config.extra_javascript %}
<script src="{{ path | url }}"></script>
{% if path.endswith(".mjs") %}
<script type="module" src="{{ path | url }}"></script>
{% else %}
<script src="{{ path | url }}"></script>
{% endif %}
{% endfor %}
{% endblock %}
</body>
Expand Down
6 changes: 5 additions & 1 deletion src/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,11 @@

<!-- Custom JavaScript -->
{% for path in config.extra_javascript %}
<script src="{{ path | url }}"></script>
{% if path.endswith(".mjs") %}
<script type="module" src="{{ path | url }}"></script>
{% else %}
<script src="{{ path | url }}"></script>
{% endif %}
{% endfor %}
{% endblock %}
</body>
Expand Down

0 comments on commit 530f844

Please sign in to comment.