File tree Expand file tree Collapse file tree 6 files changed +33
-30
lines changed
_javascript/modules/components/toc Expand file tree Collapse file tree 6 files changed +33
-30
lines changed Original file line number Diff line number Diff line change 9999
100100 <!-- Scripts -->
101101
102- {% unless site.theme_mode %}
103- < script src ="{{ '/assets/js/dist/theme.min.js' | relative_url }} "> </ script >
104- {% endunless %}
102+ < script src ="{{ '/assets/js/dist/theme.min.js' | relative_url }} "> </ script >
105103
106104 {% include js-selector.html lang=lang %}
107105
Original file line number Diff line number Diff line change 11<!-- Display GoatCounter pageviews -->
22< script >
3- let pv = document . getElementById ( 'pageviews' ) ;
3+ document . addEventListener ( 'DOMContentLoaded' , ( ) => {
4+ const pv = document . getElementById ( 'pageviews' ) ;
45
5- if ( pv !== null ) {
6- const uri = location . pathname . replace ( / \/ $ / , '' ) ;
7- const url = `https://{{ site.analytics.goatcounter.id }}.goatcounter.com/counter/${ encodeURIComponent ( uri ) } .json` ;
6+ if ( pv !== null ) {
7+ const uri = location . pathname . replace ( / \/ $ / , '' ) ;
8+ const url = `https://{{ site.analytics.goatcounter.id }}.goatcounter.com/counter/${ encodeURIComponent ( uri ) } .json` ;
89
9- fetch ( url )
10- . then ( ( response ) => response . json ( ) )
11- . then ( ( data ) => {
12- const count = data . count . replace ( / \s / g, '' ) ;
13- pv . innerText = new Intl . NumberFormat ( ) . format ( count ) ;
14- } )
15- . catch ( ( error ) => {
16- pv . innerText = '1' ;
17- } ) ;
18- }
10+ fetch ( url )
11+ . then ( ( response ) => response . json ( ) )
12+ . then ( ( data ) => {
13+ const count = data . count . replace ( / \s / g, '' ) ;
14+ pv . innerText = new Intl . NumberFormat ( ) . format ( count ) ;
15+ } )
16+ . catch ( ( error ) => {
17+ pv . innerText = '1' ;
18+ } ) ;
19+ }
20+ } ) ;
1921</ script >
Original file line number Diff line number Diff line change 22
33{% if enable_toc %}
44 < div class ="toc-border-cover z-3 "> </ div >
5- < section id ="toc-wrapper " class ="position-sticky ps-0 pe-4 ">
5+ < section id ="toc-wrapper " class ="invisible position-sticky ps-0 pe-4 pb -4 ">
66 < h2 class ="panel-heading ps-3 pb-2 mb-0 "> {{- site.data.locales[include.lang].panel.toc -}}</ h2 >
77 < nav id ="toc "> </ nav >
88 </ section >
Original file line number Diff line number Diff line change @@ -15,8 +15,11 @@ export class TocDesktop {
1515 }
1616
1717 static init ( ) {
18- if ( document . getElementById ( 'toc-wrapper' ) ) {
18+ const $tocWrapper = document . getElementById ( 'toc-wrapper' ) ;
19+
20+ if ( $tocWrapper ) {
1921 tocbot . init ( this . options ) ;
22+ $tocWrapper . classList . remove ( 'invisible' ) ;
2023 }
2124 }
2225}
Original file line number Diff line number Diff line change @@ -234,14 +234,11 @@ header {
234234@keyframes fade-up {
235235 from {
236236 opacity : 0 ;
237- position : relative ;
238- top : 2rem ;
237+ margin-top : 4rem ;
239238 }
240239
241240 to {
242241 opacity : 1 ;
243- position : relative ;
244- top : 0 ;
245242 }
246243}
247244
@@ -263,7 +260,7 @@ header {
263260 -webkit-animation : fade- up 0.8s ;
264261 animation : fade- up 0.8s ;
265262 overflow-y : auto ;
266- max-height : calc ( 100vh - 2 rem ) ;
263+ max-height : 100vh ;
267264 scrollbar-width : none ;
268265 margin-top : 2rem ;
269266
@@ -336,7 +333,7 @@ header {
336333 position : fixed ;
337334 bottom : 0 ;
338335 width : 15% ;
339- height : 3 .25rem ;
336+ height : 2 .25rem ;
340337 margin-left : -1px ;
341338 background : linear-gradient (transparent , var (--main-bg ) 70% );
342339 }
Original file line number Diff line number Diff line change @@ -11,11 +11,11 @@ const DIST = 'assets/js/dist';
1111const banner = `/*!
1212 * ${ pkg . name } v${ pkg . version } | © ${ pkg . since } ${ pkg . author } | ${ pkg . license } Licensed | ${ pkg . homepage }
1313 */` ;
14-
1514const frontmatter = `---\npermalink: /:basename\n---\n` ;
16-
1715const isProd = process . env . BUILD === 'production' ;
1816
17+ let hasWatched = false ;
18+
1919function cleanup ( ) {
2020 fs . rmSync ( DIST , { recursive : true , force : true } ) ;
2121 console . log ( `> Directory "${ DIST } " has been cleaned.` ) ;
@@ -39,6 +39,11 @@ function build(
3939 { src = SRC_DEFAULT , jekyll = false , outputName = null } = { }
4040) {
4141 const input = `${ src } /${ filename } .js` ;
42+ const shouldWatch = hasWatched ? false : true ;
43+
44+ if ( ! hasWatched ) {
45+ hasWatched = true ;
46+ }
4247
4348 return {
4449 input,
@@ -49,9 +54,7 @@ function build(
4954 banner,
5055 sourcemap : ! isProd && ! jekyll
5156 } ,
52- watch : {
53- include : input
54- } ,
57+ ...( shouldWatch && { watch : { include : `${ SRC_DEFAULT } /**/*.js` } } ) ,
5558 plugins : [
5659 babel ( {
5760 babelHelpers : 'bundled' ,
You can’t perform that action at this time.
0 commit comments