File tree Expand file tree Collapse file tree 5 files changed +26
-20
lines changed
Expand file tree Collapse file tree 5 files changed +26
-20
lines changed Original file line number Diff line number Diff line change @@ -52,11 +52,21 @@ export default {
5252 ) ;
5353
5454 const sideBarProps = {
55- versions : versions . map ( ( { version } ) => {
55+ versions : versions . map ( ( { version, isLts , isCurrent } ) => {
5656 const parsed = getVersionFromSemVer ( version ) ;
57+ let label = `v${ parsed } ` ;
58+
59+ if ( isLts ) {
60+ label += ' (LTS)' ;
61+ }
62+
63+ if ( isCurrent ) {
64+ label += ' (Current)' ;
65+ }
66+
5767 return {
5868 value : getVersionURL ( parsed , entry . api ) ,
59- label : `v ${ parsed } ` ,
69+ label,
6070 } ;
6171 } ) ,
6272 currentVersion : `v${ version . version } ` ,
Original file line number Diff line number Diff line change 1- import { useState , useEffect } from 'react' ;
1+ import { useState } from 'react' ;
22
33/**
44 * This hook provides theme management functionality
55 */
66export const useTheme = ( ) => {
7- const [ theme , setTheme ] = useState ( 'light' ) ;
8-
9- useEffect ( ( ) => {
10- // Get initial theme from HTML or fallback to system preference
11- const htmlElement = document . documentElement ;
12- const currentTheme = htmlElement . getAttribute ( 'data-theme' ) ;
13-
14- const initialTheme =
15- currentTheme ||
16- localStorage . getItem ( 'theme' ) ||
17- ( window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches
18- ? 'dark'
19- : 'light' ) ;
20-
21- setTheme ( initialTheme ) ;
22- htmlElement . setAttribute ( 'data-theme' , initialTheme ) ;
23- } , [ ] ) ;
7+ const [ theme , setTheme ] = useState ( ( ) =>
8+ CLIENT ? document . documentElement . getAttribute ( 'data-theme' ) : 'light'
9+ ) ;
2410
2511 /**
2612 * Toggles the theme between 'light' and 'dark'.
Original file line number Diff line number Diff line change 33< head >
44 < title > {{title}}</ title >
55 < link rel ="stylesheet " href ="styles.css " />
6+ < script >
7+ // This script runs before the document renders
8+ document . documentElement . setAttribute ( 'data-theme' , localStorage . getItem ( 'theme' ) ||
9+ ( matchMedia ( '(prefers-color-scheme: dark)' ) . matches ? 'dark' : 'light' ) ) ;
10+ </ script >
611</ head >
712< body >
813 < div id ="root "> {{{dehydrated}}}</ div >
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ const NODE_VERSIONS_REGEX = /\* \[Node\.js ([0-9.]+)\]\S+ (.*)\r?\n/g;
1010// A ReGeX for checking if a Node.js version is an LTS release
1111const NODE_LTS_VERSION_REGEX = / L o n g T e r m S u p p o r t / i;
1212
13+ // A ReGeX for checking if a Node.js version is the Current release
14+ const NODE_CURRENT_VERSION_REGEX = / C u r r e n t / i;
15+
1316/**
1417 * Retrieves the Node.js CHANGELOG.md via a Network Request,
1518 * used when a non-file protocol is provided
@@ -56,6 +59,7 @@ const createNodeReleases = changelogPath => {
5659 return nodeMajors . map ( match => ( {
5760 version : coerce ( match [ 1 ] ) ,
5861 isLts : NODE_LTS_VERSION_REGEX . test ( match [ 2 ] ) ,
62+ isCurrent : NODE_CURRENT_VERSION_REGEX . test ( match [ 2 ] ) ,
5963 } ) ) ;
6064 } ;
6165
Original file line number Diff line number Diff line change @@ -114,5 +114,6 @@ declare global {
114114 export interface ApiDocReleaseEntry {
115115 version : SemVer ;
116116 isLts : boolean ;
117+ isCurrent : boolean ;
117118 }
118119}
You can’t perform that action at this time.
0 commit comments