mirror of
https://github.com/nunocoracao/blowfish.git
synced 2025-01-23 06:55:43 -06:00
Merge pull request #1126 from v20100v/dev
🐛 Shortcodes gallery (non-unique id, multiple loading <script> tag)
This commit is contained in:
commit
d17678b85f
5 changed files with 37 additions and 17 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -29,3 +29,4 @@ node_modules
|
||||||
._*
|
._*
|
||||||
.Spotlight-V100
|
.Spotlight-V100
|
||||||
.Trashes
|
.Trashes
|
||||||
|
.idea
|
||||||
|
|
24
assets/js/shortcodes/gallery.js
Normal file
24
assets/js/shortcodes/gallery.js
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
function _getDefaultPackeryOptions() {
|
||||||
|
return {
|
||||||
|
percentPosition: true,
|
||||||
|
gutter: 5,
|
||||||
|
resize: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
(function init() {
|
||||||
|
window.addEventListener("DOMContentLoaded", (event) => {
|
||||||
|
console.groupCollapsed('[DEBUG] Gallery feature enable');
|
||||||
|
let packeries = [];
|
||||||
|
let nodeGalleries = document.querySelectorAll('.gallery');
|
||||||
|
|
||||||
|
nodeGalleries.forEach(nodeGallery => {
|
||||||
|
// TODO : implement a reader of Packery configuration _getPackeryOptions; for example by reading data-attribute
|
||||||
|
let packery = new Packery(nodeGallery, _getDefaultPackeryOptions());
|
||||||
|
packeries.push(packery);
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("Galleries founded and initialized with packery", packeries);
|
||||||
|
console.groupEnd();
|
||||||
|
});
|
||||||
|
})();
|
|
@ -48,8 +48,12 @@
|
||||||
|
|
||||||
{{/* Packery */}}
|
{{/* Packery */}}
|
||||||
{{ if .Page.HasShortcode "gallery" }}
|
{{ if .Page.HasShortcode "gallery" }}
|
||||||
{{ $packeryLib := resources.Get "lib/packery/packery.pkgd.min.js" }}
|
{{ $packeryLib := resources.Get "lib/packery/packery.pkgd.min.js" }}
|
||||||
<script defer src="{{ $packeryLib.RelPermalink }}" integrity="{{ $packeryLib.Data.Integrity }}"></script>
|
<script defer src="{{ $packeryLib.RelPermalink }}" integrity="{{ $packeryLib.Data.Integrity }}"></script>
|
||||||
|
|
||||||
|
{{ $jsShortcodeGallery := resources.Get "js/shortcodes/gallery.js" }}
|
||||||
|
{{ $jsShortcodeGallery = $jsShortcodeGallery | resources.Minify | resources.Fingerprint "sha512" }}
|
||||||
|
<script type="text/javascript" src="{{ $jsShortcodeGallery.RelPermalink }}" integrity="{{ $jsShortcodeGallery.Data.Integrity }}"></script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{/* tw-elements */}}
|
{{/* tw-elements */}}
|
||||||
|
|
|
@ -1,15 +1,6 @@
|
||||||
{{ $id := delimit (slice "gallery" .Ordinal now.UnixNano) "-" }}
|
{{ $random := delimit (shuffle (seq 1 9)) "" }}
|
||||||
|
{{ $id := delimit (slice "gallery" $random now.UnixNano) "-" }}
|
||||||
|
|
||||||
<div id="{{ $id }}">
|
<div id="{{ $id }}" class="gallery">
|
||||||
{{ .Inner }}
|
{{ .Inner }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
|
||||||
$(window).on("load", function () {
|
|
||||||
$('#{{ $id }}').packery({
|
|
||||||
percentPosition: true,
|
|
||||||
gutter: 5,
|
|
||||||
resize: true
|
|
||||||
});
|
|
||||||
})
|
|
||||||
</script>
|
|
|
@ -3,12 +3,12 @@
|
||||||
"version": "2.47.2",
|
"version": "2.47.2",
|
||||||
"description": "Blowfish theme for Hugo",
|
"description": "Blowfish theme for Hugo",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"fullinstall": "npm run preinstall && npm install && npm run postinstall",
|
|
||||||
"preinstall": "rimraf assets/vendor",
|
|
||||||
"postinstall": "vendor-copy",
|
"postinstall": "vendor-copy",
|
||||||
"assets": "rimraf assets/vendor && vendor-copy",
|
"assets": "rimraf assets/vendor && vendor-copy",
|
||||||
"dev": "NODE_ENV=development ./node_modules/tailwindcss/lib/cli.js -i ./assets/css/main.css -o ./assets/css/compiled/main.css --jit -w",
|
"dev": "NODE_ENV=development ./node_modules/tailwindcss/lib/cli.js -i ./assets/css/main.css -o ./assets/css/compiled/main.css --jit -w",
|
||||||
"build": "NODE_ENV=production ./node_modules/tailwindcss/lib/cli.js -i ./assets/css/main.css -o ./assets/css/compiled/main.css --jit",
|
"build": "NODE_ENV=production ./node_modules/tailwindcss/lib/cli.js -i ./assets/css/main.css -o ./assets/css/compiled/main.css --jit",
|
||||||
|
"dev-windows": "set NODE_ENV=development&&node ./node_modules/tailwindcss/lib/cli.js -i ./assets/css/main.css -o ./assets/css/compiled/main.css --jit -w",
|
||||||
|
"build-windows": "set NODE_ENV=production&&node ./node_modules/tailwindcss/lib/cli.js -i ./assets/css/main.css -o ./assets/css/compiled/main.css --jit",
|
||||||
"build-hugo": "hugo --minify -s exampleSite --themesDir ../.. -d ../docs --baseURL https://nunocoracao.github.io/blowfish/",
|
"build-hugo": "hugo --minify -s exampleSite --themesDir ../.. -d ../docs --baseURL https://nunocoracao.github.io/blowfish/",
|
||||||
"example": "hugo server -E -F --minify --source exampleSite --themesDir ../.. --buildDrafts -b http://localhost/ -p 1313",
|
"example": "hugo server -E -F --minify --source exampleSite --themesDir ../.. --buildDrafts -b http://localhost/ -p 1313",
|
||||||
"lighthouse": "lhci autorun"
|
"lighthouse": "lhci autorun"
|
||||||
|
|
Loading…
Reference in a new issue