Skip to content

Commit 0860f13

Browse files
authored
fix: append footer on about page (#329)
* fix: append footer on about page * fix: resize masonry layout after Disqus loaded
1 parent 2b6d2cd commit 0860f13

File tree

8 files changed

+29
-11
lines changed

8 files changed

+29
-11
lines changed

assets/js/grid.js

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ function initGrid() {
55
var msnry = new Masonry(grid, {
66
itemSelector: '.dream-column'
77
});
8+
if (grid.classList.contains('dream-grid-about')) {
9+
window.aboutMasonry = msnry;
10+
}
811
imagesLoaded(grid, function () {
912
return msnry.layout();
1013
});

assets/js/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ document.addEventListener('alpine:init', function () {
1515
}
1616
setTimeout(function () {
1717
_this.setThemeForUtterances();
18-
}, 6000); // Set a bigger timeout to make sure the utterances iframe is loaded.
18+
}, 6000);
1919
},
2020
mql: window.matchMedia('(prefers-color-scheme: dark)'),
2121
on: 'n',

layouts/_default/baseof.html

+3-8
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,7 @@
3333
<div class="container">
3434
{{ block "main" . }} {{ end }}
3535

36-
{{ if site.Params.zenMode }}
37-
<footer class="flex justify-between items-center gap-2 max-w-[65ch] mx-auto px-4 md:px-0 py-12">
38-
{{ else }}
39-
<footer class="flex justify-between items-center gap-2 px-4 py-12">
40-
{{ end }}
41-
{{ partial "footerLeft.html" . }}
42-
{{ partial "footerRight.html" . }}
43-
</footer>
36+
{{ partial "footer.html" . }}
4437
</div>
4538
</div>
4639
<div class="back">
@@ -50,6 +43,8 @@
5043
{{ else }}
5144
{{ partial "back.html" . }}
5245
{{ end }}
46+
47+
{{ partial "footer.html" . }}
5348
</div>
5449
</div>
5550
</div>

layouts/partials/back.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="dream-grid">
1+
<div class="dream-grid dream-grid-about">
22
{{ with site.GetPage "/about" }}
33
{{ $aboutPages := .Resources.ByType "page" }}
44
{{ range (sort $aboutPages "Date" "asc") }}

layouts/partials/disqus.html

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
this.page.identifier = '{{ default .Identifier .Context.Params.disqus_identifier }}';
77
this.page.title = '{{ default .Context.Title .Context.Params.disqus_title }}';
88
this.page.url = '{{ default .Context.Permalink .Context.Params.disqus_url }}';
9+
10+
{{ if eq .Identifier "/" }}
11+
this.callbacks.onReady.push(function () {
12+
window.aboutMasonry.layout();
13+
});
14+
{{ end }}
915
};
1016
function initDisqus() {
1117
if (["localhost", "127.0.0.1"].indexOf(window.location.hostname) != -1) {

layouts/partials/footer.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{ if site.Params.zenMode }}
2+
<footer class="flex justify-between items-center gap-2 max-w-[65ch] mx-auto px-4 md:px-0 py-12">
3+
{{ else }}
4+
<footer class="flex justify-between items-center gap-2 px-4 py-12">
5+
{{ end }}
6+
{{ partial "footerLeft.html" . }}
7+
{{ partial "footerRight.html" . }}
8+
</footer>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"private": true,
99
"scripts": {
1010
"css": "tailwindcss -i ./src/input.css -o ./assets/css/output.css",
11-
"js": "babel src --out-dir assets --presets=@babel/preset-env",
11+
"js": "babel src --out-dir assets --presets=@babel/preset-env --no-comments",
1212
"build": "npm run css && npm run js",
1313
"watch": "conc \"npm:css -- -w\" \"npm:js -- -w\""
1414
},

src/js/grid.js

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ function initGrid() {
44
itemSelector: '.dream-column',
55
})
66

7+
if (grid.classList.contains('dream-grid-about')) {
8+
// Export Masonry instance to global scope for about page,
9+
// currently used for resizing the grid after Disqus comments are loaded.
10+
window.aboutMasonry = msnry
11+
}
12+
713
imagesLoaded(grid, () => msnry.layout())
814
})
915
}

0 commit comments

Comments
 (0)