File tree Expand file tree Collapse file tree 3 files changed +15
-8
lines changed
Expand file tree Collapse file tree 3 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -39,14 +39,14 @@ export const isMobile = (): boolean => is_mobile({ tablet: true });
3939 * @param src - The source URL of the script to load
4040 * @returns A promise that resolves when the script is loaded
4141 */
42- export const loadJS = ( src : string ) : Promise < unknown > =>
42+ export const loadJS = ( src : string ) : Promise < HTMLScriptElement > =>
4343 new Promise ( ( resolve , reject ) => {
4444 let script = document . createElement ( "script" ) ;
4545 script . type = "text/javascript" ;
4646 script . src = src ;
4747 document . body . appendChild ( script ) ;
4848
49- script . onload = resolve ;
49+ script . onload = ( ) => resolve ( script ) ;
5050 script . onerror = reject ;
5151 } ) ;
5252
Original file line number Diff line number Diff line change @@ -3,17 +3,24 @@ import { onMounted } from "vue";
33import { loadJS } from " @/assets/ts/utils" ;
44
55import " @/assets/css/twikoo.css" ;
6+ import router from " @/router" ;
7+
8+ let script: HTMLScriptElement | null = null ;
69
710const URL = " https://cdn.jsdelivr.net/npm/twikoo@1.6.39/dist/twikoo.nocss.js" ;
811const ENV_ID = " https://twikoo-blog.xecades.xyz/" ;
912
10- onMounted (async () => {
11- await loadJS (URL );
13+ const loadTwikoo = async () => {
14+ if (script ) script .remove ();
15+ script = await loadJS (URL );
1216
1317 // @ts-expect-error
1418 const twikoo = window .twikoo ;
1519 await twikoo .init ({ envId: ENV_ID , el: " #twikoo" });
16- });
20+ };
21+
22+ router .afterEach (loadTwikoo );
23+ onMounted (loadTwikoo );
1724 </script >
1825
1926<template >
@@ -39,7 +46,7 @@ onMounted(async () => {
3946
4047 .tk-extras
4148 display : none ;
42-
49+
4350 .tk-input textarea
4451 padding : 0.7rem 1rem ;
4552 min-height : 170px !important ;
@@ -60,7 +67,7 @@ onMounted(async () => {
6067
6168 .tk-actions
6269 font-size : 0.8rem ;
63-
70+
6471 a
6572 color : #7 7 7 ;
6673
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ onUpdated(registerAnchor);
8080 <Metadata
8181 :breadcrumb =" meta.breadcrumb"
8282 :type =" meta.type"
83- :key =" meta.attr.title "
83+ :key =" meta.pathname "
8484 />
8585
8686 <main class =" markdown" >
You can’t perform that action at this time.
0 commit comments