Skip to content

Commit

Permalink
Use GOV.UK Frontend ES modules snippet in Nunjucks previews
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Jul 20, 2023
1 parent e2f5131 commit 01e4589
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/styles/page-template/custom/code.njk
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,9 @@ ignoreInSitemap: true
{% endblock %}

{% block bodyEnd %}
<script src="/govuk-frontend/all.js"></script>
<script type="module" src="/javascripts/govuk-frontend.min.js"></script>
<script type="module">
import { initAll } from '/javascripts/govuk-frontend.min.js'
initAll()
</script>
{% endblock %}
7 changes: 5 additions & 2 deletions src/styles/page-template/default/code.njk
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ ignoreInSitemap: true

{% block bodyEnd %}
{# Run JavaScript at end of the <body>, to avoid blocking the initial render. #}
<script src="/govuk-frontend/all.js"></script>
<script>window.GOVUKFrontend.initAll()</script>
<script type="module" src="/javascripts/govuk-frontend.min.js"></script>
<script type="module">
import { initAll } from '/javascripts/govuk-frontend.min.js'
initAll()
</script>
{% endblock %}

0 comments on commit 01e4589

Please sign in to comment.