Skip to content

Commit

Permalink
perf: use cilent side js selector for medium zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
reuixiy committed Feb 25, 2020
1 parent a995897 commit 4eb0408
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
4 changes: 2 additions & 2 deletions layouts/partials/third-party/medium-zoom.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script src="https://cdn.jsdelivr.net/npm/medium-zoom@latest/dist/medium-zoom.min.js"></script>

<script>
mediumZoom('[data-zoomable]', {
mediumZoom(document.querySelectorAll('div.post-body img'), {
background: 'hsla(var(--color-bg-h), var(--color-bg-s), var(--color-bg-l), 0.95)'
})
</script>
</script>
9 changes: 0 additions & 9 deletions layouts/partials/utils/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,6 @@
{{- end -}}
{{- end -}}

<!-- Medium Zoom -->
{{- $Content := .Scratch.Get "Content" -}}
{{- if .Site.Params.enableMediumZoom -}}
{{- $regexPatternMediumZoom := `(<img)(.[^>]+)( />|>)` -}}
{{- $regexReplacementMediumZoom := `$1$2 data-zoomable$3` -}}
{{- $Content := $Content | replaceRE $regexPatternMediumZoom $regexReplacementMediumZoom | safeHTML -}}
{{- .Scratch.Set "Content" $Content -}}
{{- end -}}

<!-- Custom -->
{{- partial "custom/content.html" . -}}

Expand Down

0 comments on commit 4eb0408

Please sign in to comment.