Skip to content

Commit

Permalink
doc: integrate with light gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
imaegoo committed Dec 12, 2023
1 parent ec21bb9 commit ddde134
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions docs/.vitepress/theme/Twikoo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down Expand Up @@ -65,11 +68,11 @@ onMounted(() => {
<component :is="'script'" defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous"></component>

<!-- lightGallery -->
<link rel="stylesheet" href="https://cdn.staticfile.org/lightgallery/2.1.8/css/lightgallery.css">
<component :is="'script'" src="https://cdn.staticfile.org/lightgallery/2.1.8/lightgallery.min.js"></component>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery@2.1.8/css/lightgallery.css">
<component :is="'script'" src="https://cdn.jsdelivr.net/npm/lightgallery@2.1.8/lightgallery.min.js"></component>

<!-- Twikoo -->
<div id="twikoo"></div>
<component :is="'script'" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/twikoo.all.min.js" ref="twikooJs"></component>
<component :is="'script'" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/twikoo.min.js" ref="twikooJs"></component>
</div>
</template>

0 comments on commit ddde134

Please sign in to comment.