File tree Expand file tree Collapse file tree 6 files changed +52
-43
lines changed Expand file tree Collapse file tree 6 files changed +52
-43
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ export default defineConfig({
2828 // Override some default components
2929 Pagination : './src/overrides/Pagination.astro' ,
3030 } ,
31+ customCss : [ './src/styles/custom.css' ] ,
3132 disable404Route : true ,
3233 sidebar : [
3334 {
Original file line number Diff line number Diff line change @@ -11,18 +11,6 @@ import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
1111 TODO
1212</StarlightPage >
1313
14- <style >
15- .side-shared {
16- color: rgb(117, 117, 255);
17- }
18- .side-client {
19- color: rgb(255, 50, 50);
20- }
21- .side-server {
22- color: rgb(232, 115, 0);
23- }
24- </style >
25-
2614<script >
2715 document.querySelectorAll('.side-type-color').forEach(el => {
2816 const type = el.textContent || '';
Original file line number Diff line number Diff line change 11---
22import StarlightPage from ' @astrojs/starlight/components/StarlightPage.astro' ;
3- import { getFunctionsByCategory , getFunctionType } from ' @src/utils/functions' ;
3+ import { getFunctionsByCategory , getFunctionInfo } from ' @src/utils/functions' ;
44
55const functionsByCategory = getFunctionsByCategory ();
66---
@@ -17,30 +17,10 @@ const functionsByCategory = getFunctionsByCategory();
1717 <summary >{ category } functions</summary >
1818 <ul >
1919 { funcs .map (func => (
20- <li ><a href = { ` /${func .id } ` } >{ func .id } </a > (<span class = " side-type-color " > { getFunctionType (func .data )} </span >)</li >
20+ <li ><a href = { ` /${func .id } ` } >{ func .id } </a > (<span class = { " side-" + getFunctionInfo ( func . data ). type } > { getFunctionInfo (func .data ). typePretty } </span >)</li >
2121 ))}
2222 </ul >
2323 </details >
2424 </section >
2525 ))}
2626</StarlightPage >
27-
28- <style >
29- .side-shared {
30- color: rgb(117, 117, 255);
31- }
32- .side-client {
33- color: rgb(255, 50, 50);
34- }
35- .side-server {
36- color: rgb(232, 115, 0);
37- }
38- </style >
39-
40- <script >
41- document.querySelectorAll('.side-type-color').forEach(el => {
42- const type = el.textContent || '';
43- el.classList.add(`side-${type.toLowerCase()}`);
44- });
45-
46- </script >
Original file line number Diff line number Diff line change 11---
22import StarlightPage from ' @astrojs/starlight/components/StarlightPage.astro' ;
33import { getCollection } from ' astro:content' ;
4- import { getFunctionType } from ' @src/utils/functions' ;
4+ import { getFunctionInfo } from ' @src/utils/functions' ;
55
66export async function getStaticPaths() {
77 const functions = await getCollection (' functions' );
@@ -12,13 +12,26 @@ export async function getStaticPaths() {
1212}
1313
1414const { func } = Astro .props ;
15+
16+ const funcInfo = getFunctionInfo (func .data );
17+
18+ const funcType = funcInfo .type ;
19+ const funcTypePretty = funcInfo .typePretty ;
20+ const funcTypeClass = ` side-${funcType } ` ;
21+
22+ const funcPair = funcInfo .pair ;
1523---
24+
1625<StarlightPage frontmatter ={ {
1726 template: ' doc' ,
1827 title: func .id ,
1928 tableOfContents: false ,
2029}} >
21- <div >
22- { getFunctionType (func .data )}
23- </div >
30+ <p ><strong >Type:</strong > <span class ={ funcTypeClass } >{ funcTypePretty } </span ></p >
31+
32+ { funcPair && (
33+ <p >Pair: <a href = { funcPair } >{ funcPair } </a ></p >
34+ )}
35+
36+ <p >{ funcInfo .description } </p >
2437</StarlightPage >
Original file line number Diff line number Diff line change 1+ /* Custom MTA Wiki CSS */
2+
3+ /* Styling for "Client-side / Server-side / Shared" */
4+ .side-shared {
5+ color : rgb (117 , 117 , 255 );
6+ }
7+ .side-client {
8+ color : rgb (255 , 50 , 50 );
9+ }
10+ .side-server {
11+ color : rgb (232 , 115 , 0 );
12+ }
Original file line number Diff line number Diff line change @@ -12,17 +12,32 @@ type FunctionsByTypeByCategory = {
1212 server : FunctionsByCategory ;
1313} ;
1414
15- type FunctionData = {
16- shared ?: object ;
17- client ?: object ;
18- server ?: object ;
15+ export type FunctionData = {
16+ shared ?: any ;
17+ client ?: any ;
18+ server ?: any ;
1919} ;
2020
21- export function getFunctionType ( data : FunctionData ) : 'shared' | 'client' | 'server' {
21+ function getFunctionType ( data : FunctionData ) : 'shared' | 'client' | 'server' {
2222 if ( data . shared ) return 'shared' ;
2323 if ( data . client ) return 'client' ;
2424 return 'server' ;
2525}
26+ function getFunctionTypePretty ( data : FunctionData ) : string {
27+ const funcType = getFunctionType ( data ) ;
28+ if ( funcType === 'shared' ) return 'Shared' ;
29+ if ( funcType === 'client' ) return 'Client-side' ;
30+ return 'Server-side' ;
31+ }
32+
33+ export function getFunctionInfo ( data : FunctionData ) : any {
34+ return {
35+ description : data . shared ?. description || data . client ?. description || data . server ?. description || '' ,
36+ type : getFunctionType ( data ) ,
37+ typePretty : getFunctionTypePretty ( data ) ,
38+ pair : data . shared ?. pair || data . client ?. pair || data . server ?. pair || false ,
39+ } ;
40+ }
2641
2742const functionsCollection = await getCollection ( 'functions' ) ;
2843let functionsByCategory : FunctionsByCategory = { } ;
You can’t perform that action at this time.
0 commit comments