Skip to content

Commit

Permalink
Chg: make usable without js
Browse files Browse the repository at this point in the history
  • Loading branch information
inkhey committed Aug 29, 2024
1 parent f856f41 commit 1d495f2
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion assets/css/_styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ section.gallery {
border-radius: 1rem;
}

& > img, & figure > img {
& > img, & figure > img, & noscript > img, & noscript > figure > img {
transition-duration: 150ms;
transition-property: all;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
Expand Down
10 changes: 10 additions & 0 deletions assets/css/no_script.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

img.lazyload {
display: none;
}

#gallery {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 20px;
}
3 changes: 3 additions & 0 deletions layouts/partials/album-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
{{ with $gallery }}
<a class="card" href="{{ .page.RelPermalink }}" title="{{ .page.Title }}">
<figure style="background-color: {{ .color }}">
<noscript>
<img loading="lazy" width="{{ .thumbnail.Width }}" height="{{ .thumbnail.Height }}" src="{{ .thumbnail.RelPermalink }}" alt="{{ .page.Title }}" />
</noscript>
<img class="lazyload" width="{{ .thumbnail.Width }}" height="{{ .thumbnail.Height }}" data-src="{{ .thumbnail.RelPermalink }}" alt="{{ .page.Title }}" />
</figure>
<div>
Expand Down
9 changes: 8 additions & 1 deletion layouts/partials/gallery.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<section class="gallery">
<div id="gallery" style="visibility: hidden; height: 1px; overflow: hidden">
<div id="gallery" style="overflow: hidden">
{{ $images := slice }}
{{ range $image := .Resources.ByType "image" }}
{{ $title := "" }}
Expand Down Expand Up @@ -27,6 +27,9 @@
{{ $color := index $thumbnail.Colors 0 | default "transparent" }}
<a class="gallery-item" href="{{ $image.RelPermalink }}" data-pswp-src="{{ $full.RelPermalink }}" data-pswp-width="{{ $full.Width }}" data-pswp-height="{{ $full.Height }}" title="{{ .Title }}" itemscope itemtype="https://schema.org/ImageObject" style="aspect-ratio: {{ $thumbnail.Width }} / {{ $thumbnail.Height }}">
<figure style="background-color: {{ $color }}; aspect-ratio: {{ $thumbnail.Width }} / {{ $thumbnail.Height }}">
<noscript>
<img loading="lazy" width="{{ $thumbnail.Width }}" height="{{ $thumbnail.Height }}" src="{{ $thumbnail.RelPermalink }}" alt="{{ .Title }}" />
</noscript>
<img class="lazyload" width="{{ $thumbnail.Width }}" height="{{ $thumbnail.Height }}" data-src="{{ $thumbnail.RelPermalink }}" alt="{{ .Title }}" />
</figure>
<meta itemprop="contentUrl" content="{{ $image.RelPermalink }}" />
Expand All @@ -38,4 +41,8 @@
</a>
{{ end }}
</div>
<script>menu =document.getElementById('menu')
menu.style("visibility") = "hidden";
menu.style("height") = "1px";
</script>
</section>
3 changes: 3 additions & 0 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
{{ partial "opengraph.html" . }}
{{ $css := resources.Get "/css/main.scss" | toCSS | minify | fingerprint }}
<link rel="stylesheet" href="{{ $css.RelPermalink }}" />
{{ $css_noscript:= resources.Get "/css/no_script.css" | toCSS | minify | fingerprint }}
<noscript><link rel="stylesheet" href="{{ $css_noscript.RelPermalink }}" /></noscript>

{{ $params := dict
"closeTitle" (i18n "closeTitle")
"zoomTitle" (i18n "zoomTitle")
Expand Down
3 changes: 2 additions & 1 deletion layouts/partials/menu.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ with site.Menus.main }}
<menu class="hidden" id="menu">
<menu id="menu">
{{ range . }}
<li itemscope itemtype="http://www.schema.org/SiteNavigationElement">
<a aria-current="{{ or (page.IsMenuCurrent .Menu .) (page.HasMenuCurrent .Menu .) }}" href="{{ .URL }}" itemprop="url">
Expand All @@ -8,4 +8,5 @@
</li>
{{ end }}
</menu>
<script>document.getElementById('menu').classList.add("hidden");;</script>
{{ end }}

0 comments on commit 1d495f2

Please sign in to comment.