11let allMenus , navLinks , versionsLinks ;
22
3+ const STORYBOOK_PATH_META_SELECTOR = 'meta[name="storybook_path"]' ;
4+
35function hideTips ( ) {
46 const tipElement = document . getElementById ( 'tip' ) ;
57 const tipContainer = document . getElementById ( 'tip-container' ) ;
@@ -58,11 +60,11 @@ function buildPageToC() {
5860 hasInnerContainers : true ,
5961 } ) ;
6062
61- const storybookPathMeta = document . querySelector (
62- 'meta[name="storybook_path"]'
63- ) ;
63+ const storybookPathMetaContent = document . querySelector (
64+ STORYBOOK_PATH_META_SELECTOR
65+ ) . content ;
6466 const tocList = document . querySelector ( '.toc-list' ) ;
65- if ( ! tocList || ! storybookPathMeta ) {
67+ if ( ! tocList || ! storybookPathMetaContent ) {
6668 return ;
6769 }
6870
@@ -71,13 +73,13 @@ function buildPageToC() {
7173
7274 const storybookLink = document . createElement ( 'a' ) ;
7375 storybookLink . className = 'toc-link' ;
74- storybookLink . href = `https://react-admin-storybook.vercel.app?path=/story/${ storybookPathMeta . content } ` ;
76+ storybookLink . href = `https://react-admin-storybook.vercel.app?path=/story/${ storybookPathMetaContent } ` ;
7577 storybookLink . textContent = 'Storybook' ;
7678 storybookLink . target = '_blank' ;
7779 storybookLink . rel = 'noopener noreferrer' ;
7880
7981 const storybookLaunchIcon = document . createElement ( 'img' ) ;
80- storybookLaunchIcon . src = '/img/icons/launch.png' ;
82+ storybookLaunchIcon . src = '. /img/icons/launch.png' ;
8183 storybookLaunchIcon . alt = 'Open Storybook' ;
8284 storybookLaunchIcon . className = 'toc-link-icon' ;
8385
@@ -106,6 +108,15 @@ function replaceContent(text) {
106108 content . innerHTML = tmpContent . innerHTML ;
107109 }
108110
111+ const newStorybookPathMeta = tmpElement . querySelector (
112+ STORYBOOK_PATH_META_SELECTOR
113+ ) ;
114+
115+ const newStorybookPathContent = newStorybookPathMeta ?. content ?? '' ;
116+ document
117+ . querySelector ( STORYBOOK_PATH_META_SELECTOR )
118+ . setAttribute ( 'content' , newStorybookPathContent ) ;
119+
109120 window . scrollTo ( 0 , 0 ) ;
110121
111122 buildPageToC ( ) ;
0 commit comments