diff --git a/.gitignore b/.gitignore index 6227a0dc..e61adca4 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ node_modules ._* .Spotlight-V100 .Trashes +.idea diff --git a/assets/js/shortcodes/gallery.js b/assets/js/shortcodes/gallery.js new file mode 100644 index 00000000..bc61fadb --- /dev/null +++ b/assets/js/shortcodes/gallery.js @@ -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(); + }); +})(); \ No newline at end of file diff --git a/layouts/partials/vendor.html b/layouts/partials/vendor.html index 2171288b..9e9a1076 100644 --- a/layouts/partials/vendor.html +++ b/layouts/partials/vendor.html @@ -48,8 +48,12 @@ {{/* Packery */}} {{ if .Page.HasShortcode "gallery" }} -{{ $packeryLib := resources.Get "lib/packery/packery.pkgd.min.js" }} - + {{ $packeryLib := resources.Get "lib/packery/packery.pkgd.min.js" }} + + + {{ $jsShortcodeGallery := resources.Get "js/shortcodes/gallery.js" }} + {{ $jsShortcodeGallery = $jsShortcodeGallery | resources.Minify | resources.Fingerprint "sha512" }} + {{ end }} {{/* tw-elements */}} diff --git a/layouts/shortcodes/gallery.html b/layouts/shortcodes/gallery.html index f03d709d..0aa82415 100644 --- a/layouts/shortcodes/gallery.html +++ b/layouts/shortcodes/gallery.html @@ -1,15 +1,6 @@ -{{ $id := delimit (slice "gallery" .Ordinal now.UnixNano) "-" }} +{{ $random := delimit (shuffle (seq 1 9)) "" }} +{{ $id := delimit (slice "gallery" $random now.UnixNano) "-" }} -
+ - - \ No newline at end of file +
\ No newline at end of file diff --git a/package.json b/package.json index ad9b7208..171b65d4 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,12 @@ "version": "2.47.2", "description": "Blowfish theme for Hugo", "scripts": { - "fullinstall": "npm run preinstall && npm install && npm run postinstall", - "preinstall": "rimraf assets/vendor", "postinstall": "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", "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/", "example": "hugo server -E -F --minify --source exampleSite --themesDir ../.. --buildDrafts -b http://localhost/ -p 1313", "lighthouse": "lhci autorun"