From ddde1347513f73ba7a69a7e856707992ad2e2d0a Mon Sep 17 00:00:00 2001 From: iMaeGoo Date: Tue, 12 Dec 2023 17:53:53 +0800 Subject: [PATCH] doc: integrate with light gallery --- docs/.vitepress/theme/Twikoo.vue | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/.vitepress/theme/Twikoo.vue b/docs/.vitepress/theme/Twikoo.vue index 841259b2e..f6b500ad0 100644 --- a/docs/.vitepress/theme/Twikoo.vue +++ b/docs/.vitepress/theme/Twikoo.vue @@ -16,14 +16,17 @@ function initTwikoo () { } function initLightGallery () { - // This function is compiled to ES5 - var commentContents = document.getElementsByClassName('tk-content'); + var commentContents = [ + ...document.getElementsByClassName('vp-doc'), + ...document.getElementsByClassName('tk-content') + ]; for (var i = 0; i < commentContents.length; i++) { var commentItem = commentContents[i]; var imgEls = commentItem.getElementsByTagName('img'); if (imgEls.length > 0) { for (var j = 0; j < imgEls.length; j++) { var imgEl = imgEls[j]; + if (imgEl.parentElement.tagName === 'A') continue; var aEl = document.createElement('a'); aEl.setAttribute('class', 'tk-lg-link'); aEl.setAttribute('href', imgEl.getAttribute('src')); @@ -65,11 +68,11 @@ onMounted(() => { - - + +
- +