11import { Title } from '@solidjs/meta' ;
22import { useLocation , useNavigate , useParams } from '@solidjs/router' ;
3- import { createEffect , createMemo , createSignal , onCleanup , Show } from 'solid-js' ;
3+ import { createEffect , createMemo , createSignal , Show } from 'solid-js' ;
44import { ProjectParser } from 'typedoc-json-parser' ;
5+ import { DocsContents } from '../components/docs/Contents' ;
56import { DocsLoading } from '../components/docs/Loading' ;
67import { NavigationDocs } from '../components/docs/Navigation' ;
78import { DocsClasses , DocsEnums , DocsInterfaces , DocsMethods , DocsReadme } from '../components/docs/packages' ;
8- import { DocsSideBar } from '../components/docs/SideBar' ;
99import type { ExtraClassMethod } from '../components/types' ;
1010import DevelopmentIntro from '../docs/development/intro.mdx' ;
1111import WelcomFaq from '../docs/welcome/faq.mdx' ;
@@ -28,36 +28,6 @@ const Docs = () => {
2828
2929 const location = useLocation ( ) ;
3030 const [ selectedPkg , setPackage ] = createSignal < ProjectParser > ( ) ;
31- const [ scrollValue , setScroll ] = createSignal ( window . innerWidth < 640 ? 0 : window . scrollY ) ;
32- const updateScroll = ( forced = false , smooth = false ) => {
33- if ( forced ) {
34- setTimeout ( ( ) => {
35- updateScroll ( false , true ) ;
36- } , 50 ) ;
37-
38- return ;
39- }
40-
41- setScroll ( window . scrollY ) ;
42-
43- const sideBar = document . getElementById ( 'sidebar' ) ;
44-
45- if ( sideBar ) {
46- const perc = scrollValue ( ) / document . body . scrollHeight ;
47- const max = sideBar . scrollHeight - sideBar . clientHeight ;
48-
49- sideBar . scrollTo ( { top : perc * max , behavior : smooth ? 'smooth' : 'auto' } ) ;
50- }
51- } ;
52-
53- const ev = ( ) => updateScroll ( ) ;
54-
55- if ( window . innerWidth > 640 ) window . addEventListener ( 'scroll' , ev , { passive : true } ) ;
56-
57- onCleanup ( ( ) => {
58- window . removeEventListener ( 'scroll' , ev ) ;
59- } ) ;
60-
6131 const choosePackage = async ( name : string ) => {
6232 if ( pkgs . loading ) {
6333 setTimeout ( ( ) => {
@@ -69,10 +39,10 @@ const Docs = () => {
6939
7040 const found = pkgs ( ) . find ( ( x ) => x . name === name ) ;
7141 const stored = localStorage . getItem ( `docs-${ name } ` ) ;
72- let json : ProjectParser . JSON | undefined ;
42+ let json : ProjectParser . Json | undefined ;
7343
7444 if ( stored ) {
75- const parsed : { docs : ProjectParser . JSON ; date : Date } = JSON . parse ( stored ) ;
45+ const parsed : { docs : ProjectParser . Json ; date : Date } = JSON . parse ( stored ) ;
7646
7747 if ( new Date ( ) . getTime ( ) - new Date ( parsed . date ) . getTime ( ) < 1000 * 60 * 10 ) {
7848 json = parsed . docs ;
@@ -92,6 +62,10 @@ const Docs = () => {
9262 if ( location . hash ) {
9363 document . getElementById ( location . hash . slice ( 1 ) ) ?. scrollIntoView ( ) ;
9464 }
65+
66+ if ( params ( ) . type === 'search' ) {
67+ const found = selectedPkg ( ) ! . find ( parseInt ( location . query . id , 10 ) ) ;
68+ }
9569 }
9670 } ;
9771
@@ -188,7 +162,6 @@ const Docs = () => {
188162 onChoosePackage = { choosePackage }
189163 onSetPackage = { setPackage }
190164 params = { params }
191- scrollValue = { scrollValue }
192165 />
193166 < div class = 'w-full overflow-x-scroll' >
194167 < div >
@@ -200,16 +173,16 @@ const Docs = () => {
200173 < DocsReadme selectedPkg = { selectedPkg } />
201174 </ Show >
202175 < Show when = { params ( ) . type === 'methods' } >
203- < DocsMethods params = { params } onUpdateScroll = { updateScroll } allMethods = { allMethods } selectedPkg = { selectedPkg } />
176+ < DocsMethods params = { params } allMethods = { allMethods } selectedPkg = { selectedPkg } />
204177 </ Show >
205178 < Show when = { params ( ) . type === 'interfaces' } >
206- < DocsInterfaces params = { params } onUpdateScroll = { updateScroll } selectedPkg = { selectedPkg } />
179+ < DocsInterfaces params = { params } selectedPkg = { selectedPkg } />
207180 </ Show >
208181 < Show when = { params ( ) . type === 'classes' } >
209- < DocsClasses params = { params } onUpdateScroll = { updateScroll } selectedPkg = { selectedPkg } />
182+ < DocsClasses params = { params } selectedPkg = { selectedPkg } />
210183 </ Show >
211184 < Show when = { params ( ) . type === 'enums' } >
212- < DocsEnums params = { params } onUpdateScroll = { updateScroll } selectedPkg = { selectedPkg } />
185+ < DocsEnums params = { params } selectedPkg = { selectedPkg } />
213186 </ Show >
214187 </ Show >
215188 < Show when = { params ( ) . category } >
@@ -231,7 +204,7 @@ const Docs = () => {
231204 </ Show >
232205 </ div >
233206 </ div >
234- < DocsSideBar params = { params } onUpdateScroll = { updateScroll } allMethods = { allMethods } scrollValue = { scrollValue } />
207+ < DocsContents params = { params } allMethods = { allMethods } />
235208 </ Show >
236209 </ div >
237210 ) ;
0 commit comments