Added support for using .mjs files in extra_javascript

This commit is contained in:
squidfunk 2023-05-30 19:40:58 +02:00
parent e8c4528b41
commit 530f84416e
No known key found for this signature in database
GPG Key ID: 5ED40BC4F9C436DF
3 changed files with 11 additions and 3 deletions

View File

@ -98,7 +98,7 @@
"items": { "items": {
"title": "Path to JavaScript file", "title": "Path to JavaScript file",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/customization/#additional-javascript", "markdownDescription": "https://squidfunk.github.io/mkdocs-material/customization/#additional-javascript",
"pattern": "\\.js($|\\?)" "pattern": "\\.m?js($|\\?)"
}, },
"uniqueItems": true, "uniqueItems": true,
"minItems": 1 "minItems": 1

View File

@ -242,7 +242,11 @@
{% block scripts %} {% block scripts %}
<script src="{{ 'assets/javascripts/bundle.b4d07000.min.js' | url }}"></script> <script src="{{ 'assets/javascripts/bundle.b4d07000.min.js' | url }}"></script>
{% for path in config.extra_javascript %} {% for path in config.extra_javascript %}
{% if path.endswith(".mjs") %}
<script type="module" src="{{ path | url }}"></script>
{% else %}
<script src="{{ path | url }}"></script> <script src="{{ path | url }}"></script>
{% endif %}
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}
</body> </body>

View File

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