Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Begin fixing landing customization #148

Open
wants to merge 4 commits into
base: release
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
finish moving around JS
indrora committed Jan 29, 2024
commit 5d73283ebc417673002218588a812bf6f780bf28
10 changes: 9 additions & 1 deletion assets/js/app.js
Original file line number Diff line number Diff line change
@@ -27,4 +27,12 @@ function toggleMenu() {
} else {
isOpen.style.display = "block";
}
};
};

window.addEventListener("DOMContentLoaded", (ev) => {
const viewers = document.querySelectorAll(".image-compare");
viewers.forEach((element, i) => {
let view = new ImageCompare(element, JSON.parse(element.dataset.icConfig) ).mount();
});

});
28 changes: 0 additions & 28 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -26,33 +26,5 @@
</div>
{{- partial "footer.html" . -}}

<!-- Lotus Docs JS -->
{{ $app := resources.Get "/js/app.js" }}
{{- if not .Site.IsServer }}
{{- $js := (slice $app) | resources.Concat "/js/bundle.js" | minify | fingerprint "sha384" }}
<script type="text/javascript" src="{{ $js.Permalink }}" integrity="{{ $js.Data.Integrity }}"></script>
{{- else }}
{{- $js := (slice $app) | resources.Concat "/js/bundle.js" }}
<script type="text/javascript" src="{{ $js.Permalink }}" {{ if hugo.IsProduction }}integrity="{{ $js.Data.Integrity }}"{{ end }}></script>
{{- end }}
<!-- Image Compare Viewer Config -->
{{ if (default false ($.Scratch.Get "image_compare_used")) }}
{{ $imagecompare := resources.Get "js/image-compare-viewer.min.js" }}
{{- if not .Site.IsServer }}
{{- $js := (slice $imagecompare) | resources.Concat "/js/image-compare.js" | minify | fingerprint "sha384" }}
<script type="text/javascript" src="{{ $js.Permalink }}" integrity="{{ $js.Data.Integrity }}"></script>
{{- else }}
{{- $js := (slice $imagecompare) | resources.Concat "/js/image-compare.js" }}
<script type="text/javascript" src="{{ $js.Permalink }}" {{ if hugo.IsProduction }}integrity="{{ $js.Data.Integrity }}"{{ end }}></script>
{{- end }}

<script>
const viewers = document.querySelectorAll(".image-compare");
viewers.forEach((element, i) => {
let view = new ImageCompare(element, JSON.parse(element.dataset.icConfig) ).mount();
});
</script>
{{ end }}

</body>
</html>
17 changes: 5 additions & 12 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
@@ -27,26 +27,19 @@
{{- end -}}
<link rel="stylesheet" href="{{ $style.RelPermalink }}" {{ if hugo.IsProduction }}integrity="{{ $style.Data.Integrity }}"{{ end -}}/>
<!-- Bootstrap JS -->
{{ $js := resources.Get "js/bootstrap.js" }}
{{- $imgviewjs := resources.Get "/js/image-compare-viewer.min.js" -}}
{{- $appjs := resources.Get "/js/app.js" -}}
{{- $bsjs := resources.Get "js/bootstrap.js" -}}
{{- $js := slice $bsjs $imgviewjs $appjs | resources.Concat "/js/bundle.js"}}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my tests show that the image-compare-viewer sources are not properly embedded:

Uncaught ReferenceError: ImageCompare is not defined
    at bundle.js:1489:20
    at NodeList.forEach (<anonymous>)
    at bundle.js:1488:15

{{ $params := dict }}
{{ $sourceMap := cond hugo.IsProduction "" "inline" }}
{{ $opts := dict "sourceMap" $sourceMap "minify" hugo.IsProduction "target" "es2018" "params" $params }}
{{ $js = $js | js.Build $opts }}
{{ if hugo.IsProduction }}
{{ $js = $js | fingerprint "sha384" }}
{{ end }}

<script src="{{ $js.RelPermalink }}" {{ if hugo.IsProduction }}integrity="{{ $js.Data.Integrity }}"{{ end -}} defer></script>
<!-- Image Compare Viewer -->
{{ if ($.Scratch.Get "image_compare_enabled") }}
{{ $imagecompare := resources.Get "js/image-compare-viewer.min.js" }}
{{- if not .Site.IsServer }}
{{- $js := (slice $imagecompare) | resources.Concat "/js/image-compare.js" | minify | fingerprint "sha384" }}
<script type="text/javascript" src="{{ $js.Permalink }}" integrity="{{ $js.Data.Integrity }}"></script>
{{- else }}
{{- $js := (slice $imagecompare) | resources.Concat "/js/image-compare.js" }}
<script type="text/javascript" src="{{ $js.Permalink }}" {{ if hugo.IsProduction }}integrity="{{ $js.Data.Integrity }}"{{ end }}></script>
{{- end }}
{{- end }}
<!-- Plausible Analytics Config -->
{{- if not .Site.IsServer }}
{{ if and (.Site.Params.plausible.scriptURL) (.Site.Params.plausible.dataDomain) -}}
2 changes: 1 addition & 1 deletion layouts/partials/landing/image_compare.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $sectionTitle := .sectionTitle }}{{ with .data }}{{ if eq .enable true }}
{{- page.Scratch.Set "image_compare_used" true -}} {{- page.Scratch.Add "imageCompareConfig" (slice (.config | jsonify | safeJS)) -}}
{{- page.Scratch.Set "image_compare_used" true -}}
<section id="{{ $sectionTitle }}">
<div class="container mt-100 mt-60">
<div class="row justify-content-center">