File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ const config: Config = {
2020 onBrokenLinks : 'throw' ,
2121 onBrokenMarkdownLinks : 'warn' ,
2222
23+ customFields : {
24+ wasmCacheBuster : String ( Date . now ( ) ) ,
25+ } ,
26+
2327 markdown : {
2428 mermaid : true ,
2529 } ,
Original file line number Diff line number Diff line change 1+ import useDocusaurusContext from '@docusaurus/useDocusaurusContext' ;
12import type { WasmModule } from '@site/src/types/paperjam' ;
23import { useEffect , useState } from 'react' ;
34
45let cachedModule : WasmModule | null = null ;
56
67export function usePaperjam ( ) {
8+ const { siteConfig } = useDocusaurusContext ( ) ;
9+ const cacheBuster =
10+ ( siteConfig . customFields ?. wasmCacheBuster as string ) || '' ;
11+
712 const [ loading , setLoading ] = useState ( ! cachedModule ) ;
813 const [ error , setError ] = useState < string | null > ( null ) ;
914 const [ paperjam , setPaperjam ] = useState < WasmModule | null > ( cachedModule ) ;
1015
1116 useEffect ( ( ) => {
1217 if ( cachedModule ) return ;
13- const wasmUrl = ' /paperjam/wasm/paperjam_wasm.js' ;
18+ const wasmUrl = ` /paperjam/wasm/paperjam_wasm.js?v= ${ cacheBuster } ` ;
1419 ( async ( ) => {
1520 try {
1621 const mod = await import ( /* webpackIgnore: true */ wasmUrl ) ;
@@ -23,7 +28,7 @@ export function usePaperjam() {
2328 setLoading ( false ) ;
2429 }
2530 } ) ( ) ;
26- } , [ ] ) ;
31+ } , [ cacheBuster ] ) ;
2732
2833 return { paperjam, loading, error } ;
2934}
You can’t perform that action at this time.
0 commit comments