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({
28
28
// Override some default components
29
29
Pagination : './src/overrides/Pagination.astro' ,
30
30
} ,
31
+ customCss : [ './src/styles/custom.css' ] ,
31
32
disable404Route : true ,
32
33
sidebar : [
33
34
{
Original file line number Diff line number Diff line change @@ -11,18 +11,6 @@ import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
11
11
TODO
12
12
</StarlightPage >
13
13
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
-
26
14
<script >
27
15
document.querySelectorAll('.side-type-color').forEach(el => {
28
16
const type = el.textContent || '';
Original file line number Diff line number Diff line change 1
1
---
2
2
import StarlightPage from ' @astrojs/starlight/components/StarlightPage.astro' ;
3
- import { getFunctionsByCategory , getFunctionType } from ' @src/utils/functions' ;
3
+ import { getFunctionsByCategory , getFunctionInfo } from ' @src/utils/functions' ;
4
4
5
5
const functionsByCategory = getFunctionsByCategory ();
6
6
---
@@ -17,30 +17,10 @@ const functionsByCategory = getFunctionsByCategory();
17
17
<summary >{ category } functions</summary >
18
18
<ul >
19
19
{ 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 >
21
21
))}
22
22
</ul >
23
23
</details >
24
24
</section >
25
25
))}
26
26
</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 1
1
---
2
2
import StarlightPage from ' @astrojs/starlight/components/StarlightPage.astro' ;
3
3
import { getCollection } from ' astro:content' ;
4
- import { getFunctionType } from ' @src/utils/functions' ;
4
+ import { getFunctionInfo } from ' @src/utils/functions' ;
5
5
6
6
export async function getStaticPaths() {
7
7
const functions = await getCollection (' functions' );
@@ -12,13 +12,26 @@ export async function getStaticPaths() {
12
12
}
13
13
14
14
const { 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 ;
15
23
---
24
+
16
25
<StarlightPage frontmatter ={ {
17
26
template: ' doc' ,
18
27
title: func .id ,
19
28
tableOfContents: false ,
20
29
}} >
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 >
24
37
</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 = {
12
12
server : FunctionsByCategory ;
13
13
} ;
14
14
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 ;
19
19
} ;
20
20
21
- export function getFunctionType ( data : FunctionData ) : 'shared' | 'client' | 'server' {
21
+ function getFunctionType ( data : FunctionData ) : 'shared' | 'client' | 'server' {
22
22
if ( data . shared ) return 'shared' ;
23
23
if ( data . client ) return 'client' ;
24
24
return 'server' ;
25
25
}
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
+ }
26
41
27
42
const functionsCollection = await getCollection ( 'functions' ) ;
28
43
let functionsByCategory : FunctionsByCategory = { } ;
You can’t perform that action at this time.
0 commit comments