File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
.vitepress/theme/composables Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,28 @@ export async function createZoom(app: App, router: Router) {
2929 } )
3030
3131 lightbox . reload = ( ) => {
32+ const blocklist = [
33+ 'youtube.com' ,
34+ 'youtu.be' ,
35+ 'rutube.ru' ,
36+ 'vimeo.com' ,
37+ 'vk.com/video' ,
38+ 'dailymotion.com' ,
39+ 'ok.ru/video' ,
40+ ]
3241 const elements = Array . from ( document . querySelectorAll ( '.VPContent.has-sidebar .vp-doc img:not(.logo)' ) )
42+ . filter ( item => {
43+ const target = item . parentElement instanceof HTMLAnchorElement ? item . parentElement : item
44+
45+ if ( ! ( target instanceof HTMLImageElement ) && ! ( target instanceof HTMLAnchorElement ) ) return false
46+
47+ try {
48+ const url = new URL ( target instanceof HTMLAnchorElement ? target . href : target . src , window . location . origin )
49+ return ! blocklist . some ( domain => url . hostname . includes ( domain ) || url . href . includes ( domain ) )
50+ } catch {
51+ return true // если невалидный url, не фильтруем
52+ }
53+ } )
3354 . map ( ( element , index ) => {
3455 const target = element . parentElement instanceof HTMLAnchorElement ? element . parentElement : element
3556 target . addEventListener ( 'click' , ( e ) => {
You can’t perform that action at this time.
0 commit comments