fix(toc): restore correct floating TOC positioning after layout refactor
Fix incorrect TOC alignment caused by outdated DOM selector in toc.js. The content reference element changed during layout refactor, breaking position calculations for the floating TOC. Updated contentColumn selector to use .main-wrapper/.container fallback, ensuring correct left offset and responsive positioning. Also adds a more robust fallback chain to prevent future regressions when layout structure changes.
This commit is contained in:
@@ -9,6 +9,31 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue TOC script when needed.
|
||||
*/
|
||||
function zeitfresser_enqueue_toc_assets() {
|
||||
|
||||
if ( ! is_singular( 'post' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! zeitfresser_has_floating_toc() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$asset = zeitfresser_asset_versioned('/js/toc.js');
|
||||
|
||||
wp_enqueue_script(
|
||||
'zeitfresser-toc',
|
||||
$asset['url'],
|
||||
[],
|
||||
$asset['version'],
|
||||
true
|
||||
);
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_enqueue_toc_assets', 20 );
|
||||
|
||||
/**
|
||||
* Return whether article TOC output is enabled.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user