1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-12-19 06:06:54 +00:00

feat(ui): show preview image in home page

This commit is contained in:
Cotes Chung
2023-03-18 06:28:44 +08:00
parent ee88cec270
commit 97b8dfeed6
39 changed files with 347 additions and 284 deletions

View File

@@ -1,27 +0,0 @@
/**
* Set up image stuff
*/
export function imgExtra() {
if ($('#core-wrapper img[data-src]') <= 0) {
return;
}
/* See: <https://github.com/dimsemenov/Magnific-Popup> */
$('.popup').magnificPopup({
type: 'image',
closeOnContentClick: true,
showCloseBtn: false,
zoom: {
enabled: true,
duration: 300,
easing: 'ease-in-out'
}
});
/* Stop shimmer when image loaded */
document.addEventListener('lazyloaded', function (e) {
const $img = $(e.target);
$img.parent().removeClass('shimmer');
});
}

View File

@@ -0,0 +1,15 @@
/**
* Set up image lazy-load
*/
export function imgLazy() {
if ($('#core-wrapper img[data-src]') <= 0) {
return;
}
/* Stop shimmer when image loaded */
document.addEventListener('lazyloaded', function (e) {
const $img = $(e.target);
$img.parent().removeClass('shimmer');
});
}

View File

@@ -0,0 +1,22 @@
/**
* Set up image popup
*
* See: https://github.com/dimsemenov/Magnific-Popup
*/
export function imgPopup() {
if ($('.popup') <= 0) {
return;
}
$('.popup').magnificPopup({
type: 'image',
closeOnContentClick: true,
showCloseBtn: false,
zoom: {
enabled: true,
duration: 300,
easing: 'ease-in-out'
}
});
}

View File

@@ -174,13 +174,7 @@ function displayPageviews(data) {
let hasInit = getInitStatus();
const rows = data.rows; /* could be undefined */
if ($('#post-list').length > 0) {
/* the Home page */
$('.post-preview').each(function () {
const path = $(this).find('a').attr('href');
tacklePV(rows, path, $(this).find('.pageviews'), hasInit);
});
} else if ($('.post').length > 0) {
if ($('.post').length > 0) {
/* the post */
const path = window.location.pathname;
tacklePV(rows, path, $('#pv'), hasInit);