File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 297297 all versioned subdirectories. Without this the browser scopes it to the
298298 current version path (e.g. /v3.1.14/) and the banner reappears on every
299299 other version. Runs immediately so it beats Material's consent check. */
300- var consentMatch = document . cookie . match ( / (?: ^ | ; \s * ) _ _ m d _ c o n s e n t = ( [ ^ ; ] * ) / ) ;
301- if ( consentMatch ) {
302- document . cookie = '__md_consent=' + consentMatch [ 1 ] + '; path=/; SameSite=Lax' ;
300+ /* Propagate mkdocs-material consent across versioned subdirectories.
301+ Each version stores consent in localStorage under its own base-path key
302+ (e.g. /utPLSQL/develop/.__consent). Copy a non-empty consent from any
303+ other version into the current version's key before Material checks it. */
304+ var baseEl = document . querySelector ( 'base' ) ;
305+ if ( baseEl ) {
306+ var CONSENT_SUFFIX = '.__consent' ;
307+ var currentConsentKey = new URL ( baseEl . href ) . pathname + CONSENT_SUFFIX ;
308+ if ( ! localStorage . getItem ( currentConsentKey ) ) {
309+ for ( var i = 0 ; i < localStorage . length ; i ++ ) {
310+ var k = localStorage . key ( i ) ;
311+ if ( k && k !== currentConsentKey && k . endsWith ( CONSENT_SUFFIX ) ) {
312+ var val = localStorage . getItem ( k ) ;
313+ if ( val && val !== '{}' ) {
314+ localStorage . setItem ( currentConsentKey , val ) ;
315+ break ;
316+ }
317+ }
318+ }
319+ }
303320 }
304321
305322 /* Hide Material's built-in header controls immediately to prevent a flash
You can’t perform that action at this time.
0 commit comments