2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-06-17 19:21:23 +03:00
This commit is contained in:
XhmikosR
2020-11-22 17:34:23 +02:00
parent 97ed344fbc
commit bc4bd10c6d
3 changed files with 9 additions and 18 deletions
+2 -2
View File
@@ -42,9 +42,9 @@ module:
target: static/favicon.ico target: static/favicon.ico
# the following are processed via Hugo pipes so we need them in the assets folder # the following are processed via Hugo pipes so we need them in the assets folder
## the following will be printed with Hugo pipes ## the following will be served as is
- source: node_modules/docsearch.js/dist/cdn/docsearch.min.js - source: node_modules/docsearch.js/dist/cdn/docsearch.min.js
target: assets/js/vendor/docsearch.min.js target: static/docs/5.1/assets/js/vendor/docsearch.min.js
## The following vendor files will be bundled together on top of local js files as /docs.js ## The following vendor files will be bundled together on top of local js files as /docs.js
- source: node_modules/anchor-js/anchor.min.js - source: node_modules/anchor-js/anchor.min.js
target: assets/js/vendor/anchor.min.js target: assets/js/vendor/anchor.min.js
+2 -15
View File
@@ -20,31 +20,18 @@
{{/* Storing the reused mount warning message */}} {{/* Storing the reused mount warning message */}}
{{ $missing_file_warning := "%s not found. Check your mounts settings and/or run `npm i`." }} {{ $missing_file_warning := "%s not found. Check your mounts settings and/or run `npm i`." }}
{{ $doc_version := site.Params.docs_version }} {{ $doc_version := site.Params.docs_version }}
{{/* Doc Search */}}
{{ if eq .Page.Layout "docs" -}}
{{ with resources.GetMatch "js/vendor/docsearch.min.js" }}
{{/* As this is a WIP, we don't customize the asset URL,
but we will after Hugo .74 and resources.Put (https://github.com/gohugoio/hugo/issues/7406):
{{ with resources.GetMatch "js/vendor/docsearch.min.js" }}
{{ $docsearch := . | resources.Put (path.Join "/docs" $doc_version "assets/js/vendor/docsearch.min.js") }}
{{ $jsAssets = $jsAssets | append $docsearch }}
*/}}
{{ $jsAssets = $jsAssets | append . }}
{{ else }}
{{ errorf $missing_file_warning "docsearch.min.js" }}
{{ end }}
{{- end }}
{{/* --- Bundle */}} {{/* --- Bundle */}}
{{ $bundle := slice }} {{ $bundle := slice }}
{{/* ----- Mounted from vendors */}} {{/* ----- Mounted from vendors */}}
{{- $vendor_assets := slice -}} {{- $vendor_assets := slice -}}
{{/* As we need to list the desired mounted files to: {{/* As we need to list the desired mounted files to:
1. Check for missing mounts and throw an error 1. Check for missing mounts and throw an error
2. Control order if need be 2. Control order if need be
3. Exclude docsearch (though there would be other ways) */}} 3. Exclude docsearch (though there would be other ways) */}}
{{ $vendor_filenames := slice "clipboard.min.js" "anchor.min.js" }} {{ $vendor_filenames := slice "anchor.min.js" "clipboard.min.js" }}
{{ range $filename := $vendor_filenames }} {{ range $filename := $vendor_filenames }}
{{ with resources.GetMatch (print "js/vendor/" .) }} {{ with resources.GetMatch (print "js/vendor/" .) }}
{{ $vendor_assets = $vendor_assets | append . }} {{ $vendor_assets = $vendor_assets | append . }}
+5 -1
View File
@@ -4,7 +4,11 @@
<script src="/docs/{{ .Site.Params.docs_version }}/dist/js/bootstrap.bundle.js"></script> <script src="/docs/{{ .Site.Params.docs_version }}/dist/js/bootstrap.bundle.js"></script>
{{- end }} {{- end }}
{{- $variant := cond (eq .Page.Layout "docs") "docs" "default" -}} {{ if eq .Page.Layout "docs" -}}
<script src="/docs/{{ .Site.Params.docs_version }}/assets/js/vendor/docsearch.min.js"></script>
{{- end }}
{{ $variant := cond (eq .Page.Layout "docs") "docs" "default" -}}
{{- range partialCached "func/get-js-assets" . $variant -}} {{- range partialCached "func/get-js-assets" . $variant -}}
<script src="{{ .RelPermalink }}"></script> <script src="{{ .RelPermalink }}"></script>
{{- end -}} {{- end -}}