This commit is contained in:
		
							parent
							
								
									dacdc533da
								
							
						
					
					
						commit
						3ab1c0c119
					
				
					 21 changed files with 2244 additions and 0 deletions
				
			
		
							
								
								
									
										34
									
								
								theme/default/js/giscus.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								theme/default/js/giscus.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,34 @@ | |||
| (() => { | ||||
|   const targetElement = document.documentElement; | ||||
|   const defaultTheme = targetElement.getAttribute('data-color-mode'); | ||||
|   changeGiscusTheme(defaultTheme); | ||||
|   const observer = new MutationObserver((mutationsList, observer) => { | ||||
|     for (const mutation of mutationsList) { | ||||
|       if (mutation.type === 'attributes') { | ||||
|         const value = targetElement.getAttribute('data-color-mode'); | ||||
|         changeGiscusTheme(value); | ||||
|       } | ||||
|     } | ||||
|   }); | ||||
| 
 | ||||
|   observer.observe(targetElement, { | ||||
|     attributes: true, | ||||
|     attributeOldValue: true, | ||||
|   }); | ||||
| 
 | ||||
|   function changeGiscusTheme(theme = 'light') { | ||||
|     const iframe = document.querySelector('.giscus-frame'); | ||||
|     if (iframe) { | ||||
|       const config = { | ||||
|         giscus: { | ||||
|           setConfig: { | ||||
|             theme: theme.toLocaleLowerCase(), | ||||
|           }, | ||||
|         }, | ||||
|       }; | ||||
|       iframe.contentWindow.postMessage(config, 'https://giscus.app'); | ||||
|       const script = document.querySelector('script[data-script-id="giscus"]'); | ||||
|       script.setAttribute('data-theme', theme); | ||||
|     } | ||||
|   } | ||||
| })(); | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue