File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ {%- if page.url contains "/wiki/" -%}
2+ < link rel ="stylesheet " href ="{{ '/assets/css/see-also.css' | relative_url }} ">
3+ < script defer src ="{{ '/assets/js/see-also.js' | relative_url }} "> </ script >
4+ {%- endif -%}
Original file line number Diff line number Diff line change 1+ .sa-panel {
2+ margin : 2.2rem 0 1rem ;
3+ padding-top : 1.2rem ;
4+ border-top : 1px solid # e5e8ec ;
5+ }
6+ .sa-heading {
7+ font-size : 1.05rem ;
8+ margin : 0 0 0.5rem ;
9+ color : # 2c3e50 ;
10+ font-weight : 600 ;
11+ }
12+ .sa-list { list-style : disc; padding-left : 1.4rem ; margin : 0 ; }
13+ .sa-list li { margin : 0.15rem 0 ; font-size : 0.95rem ; }
14+ .sa-list a { text-decoration : none; color : # 2563aa ; }
15+ .sa-list a : hover { text-decoration : underline; }
Original file line number Diff line number Diff line change 1+ ( function ( ) {
2+ 'use strict' ;
3+
4+ var path = window . location . pathname ;
5+ if ( path . indexOf ( '/wiki/' ) !== 0 ) return ;
6+
7+ var target = document . querySelector ( '.page__content' ) ;
8+ if ( ! target ) return ;
9+
10+ fetch ( '/assets/see-also.json' , { credentials : 'same-origin' } )
11+ . then ( function ( r ) {
12+ if ( ! r . ok ) throw new Error ( 'HTTP ' + r . status ) ;
13+ return r . json ( ) ;
14+ } )
15+ . then ( function ( data ) {
16+ var recs = data [ path ] ;
17+ if ( ! recs || recs . length === 0 ) return ;
18+ render ( recs ) ;
19+ } )
20+ . catch ( function ( err ) {
21+ if ( window . console && console . warn ) console . warn ( '[see-also]' , err ) ;
22+ } ) ;
23+
24+ function render ( recs ) {
25+ var panel = document . createElement ( 'section' ) ;
26+ panel . className = 'sa-panel' ;
27+ panel . setAttribute ( 'aria-label' , 'Related articles' ) ;
28+
29+ var h = document . createElement ( 'h3' ) ;
30+ h . className = 'sa-heading' ;
31+ h . textContent = 'See also' ;
32+ panel . appendChild ( h ) ;
33+
34+ var ul = document . createElement ( 'ul' ) ;
35+ ul . className = 'sa-list' ;
36+ recs . forEach ( function ( r ) {
37+ var li = document . createElement ( 'li' ) ;
38+ var a = document . createElement ( 'a' ) ;
39+ a . href = r . url ;
40+ a . textContent = r . title ;
41+ li . appendChild ( a ) ;
42+ ul . appendChild ( li ) ;
43+ } ) ;
44+ panel . appendChild ( ul ) ;
45+
46+ target . appendChild ( panel ) ;
47+ }
48+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments