mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-14 02:24:00 +01:00
24f749cb76
Also: * load any docs' third-party dependencies from node_modules (except for examples) * exclude docsearch from layouts that don't use it * preconnect to algolia only when not examples layout * switch to `RelPermalink` * refactor JS assets into partials
35 lines
1.7 KiB
HTML
35 lines
1.7 KiB
HTML
{{ if hugo.IsProduction -}}
|
|
<script src="/docs/{{ .Site.Params.docs_version }}/dist/js/bootstrap.bundle.min.js" {{ printf "integrity=%q" .Site.Params.cdn.js_bundle_hash | safeHTMLAttr }}></script>
|
|
{{ else -}}
|
|
<script src="/docs/{{ .Site.Params.docs_version }}/dist/js/bootstrap.bundle.js"></script>
|
|
{{- end }}
|
|
|
|
{{- $esbuildOptions := dict "target" "es2019" -}}
|
|
{{- $targetDocsJSPath := path.Join "/docs" .Site.Params.docs_version -}}
|
|
|
|
{{- if hugo.IsProduction -}}
|
|
{{- $esbuildOptions = merge $esbuildOptions (dict "minify" "true") -}}
|
|
{{- end }}
|
|
|
|
{{- $applicationJs := resources.Get "js/application.js" | js.Build $esbuildOptions | resources.Copy (path.Join $targetDocsJSPath "/assets/js/application.js") }}
|
|
<script src="{{ $applicationJs.RelPermalink }}"></script>
|
|
|
|
{{- if (ne .Page.Layout "examples") -}}
|
|
{{- $searchJs := resources.Get "js/search.js" | js.Build $esbuildOptions | resources.Copy (path.Join $targetDocsJSPath "/assets/js/search.js") }}
|
|
<script async src="{{ $searchJs.RelPermalink }}"></script>
|
|
{{- end -}}
|
|
|
|
{{ if eq .Page.Layout "docs" -}}
|
|
{{- /* Disable minify options for snippets.js so that the file's readable on StackBlitz */ -}}
|
|
{{- $snippetsFile := resources.Get "js/snippets.js" | js.Build (merge $esbuildOptions (dict "minify" "false")) -}}
|
|
{{- $esbuildParams := dict
|
|
"cssCdn" .Site.Params.cdn.css
|
|
"jsBundleCdn" .Site.Params.cdn.js_bundle
|
|
"docsVersion" .Site.Params.docs_version
|
|
"jsSnippetFile" $snippetsFile.Content
|
|
-}}
|
|
{{- $esbuildOptions = merge $esbuildOptions (dict "params" $esbuildParams) -}}
|
|
{{- $stackblitzJs := resources.Get "js/stackblitz.js" | js.Build $esbuildOptions | resources.Copy (path.Join $targetDocsJSPath "/assets/js/stackblitz.js") }}
|
|
<script async src="{{ $stackblitzJs.RelPermalink }}"></script>
|
|
{{- end -}}
|