Skip to content

Commit

Permalink
Docs: load all JS files from node_modules
Browse files Browse the repository at this point in the history
We load 3 JS files:

1. bootstrap.min.js
2. application.js (which has clipboard and the application code)
3. list.js (which has list.js)

All 3 JS files are loaded asynchronously.

In the future, if we need to call Bootstrap through its API, we might need to adapt the bundles.
  • Loading branch information
XhmikosR committed Dec 26, 2022
1 parent eb33a2c commit 26a51d6
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 28 deletions.
6 changes: 5 additions & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ module:
- source: node_modules/bootstrap/scss
target: assets/scss/bootstrap
- source: node_modules/bootstrap/dist/js/bootstrap.min.js
target: assets/js/bootstrap.min.js
target: assets/js/vendor/bootstrap.min.js
- source: node_modules/clipboard/dist/clipboard.min.js
target: assets/js/vendor/clipboard.min.js
- source: node_modules/list.js/dist/list.min.js
target: assets/js/vendor/list.min.js

params:
description: "Official open source SVG icon library for Bootstrap"
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/js/application.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-env browser */

/* global ClipboardJS: false */
/* global ClipboardJS:false */

(function () {
'use strict'
Expand Down
11 changes: 11 additions & 0 deletions docs/assets/js/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-env browser */

/* global List:false */

(function () {
'use strict'

new List('icons-body', {
valueNames: ['name', { data: ['tags', 'categories'] }]
})
})()
6 changes: 0 additions & 6 deletions docs/assets/js/vendor/bootstrap.min.js

This file was deleted.

7 changes: 0 additions & 7 deletions docs/assets/js/vendor/clipboard.min.js

This file was deleted.

29 changes: 17 additions & 12 deletions docs/layouts/partials/scripts.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
{{- if or .IsHome (eq .Page.Layout "font") }}
<script src="/assets/js/list.min.js"></script>
<script>
new List('icons-body', {
valueNames: ['name', { data: ['tags', 'categories'] }]
});
</script>
{{ $bootstrapJs := resources.Get "/js/vendor/bootstrap.min.js" | resources.Copy "/assets/js/vendor/bootstrap.min.js" -}}
<script async src="{{ $bootstrapJs.Permalink | relURL }}"></script>

{{- if or .IsHome (eq .Page.Layout "font") -}}
{{- $listVendor := resources.Get "js/vendor/list.min.js" -}}
{{- $listJs := resources.Get "js/list.js" -}}
{{- $listBundle := slice $listVendor $listJs | resources.Concat "assets/js/list.js" -}}

{{- if eq hugo.Environment "production" -}}
{{- $listBundle = $listBundle | resources.Minify -}}
{{- end }}
<script async src="{{ $listBundle.Permalink | relURL }}"></script>
{{- end }}

{{- $vendor := resources.Match "js/vendor/*.js" -}}
{{- $js := resources.Match "js/*.js" -}}
{{- $docsJs := append $js $vendor | resources.Concat "assets/js/application.js" -}}
{{- $clipboardVendor := resources.Get "js/vendor/clipboard.min.js" -}}
{{- $applicationJs := resources.Get "js/application.js" -}}
{{- $applicationBundle := slice $clipboardVendor $applicationJs | resources.Concat "assets/js/application.js" -}}

{{- if eq hugo.Environment "production" -}}
{{- $docsJs = $docsJs | resources.Minify -}}
{{- $applicationBundle = $applicationBundle | resources.Minify -}}
{{- end }}
<script async src="{{ $docsJs.Permalink | relURL }}"></script>
<script async src="{{ $applicationBundle.Permalink | relURL }}"></script>
1 change: 0 additions & 1 deletion docs/static/assets/js/list.min.js

This file was deleted.

111 changes: 111 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 26a51d6

Please sign in to comment.