diff --git a/web/astro.config.mjs b/web/astro.config.mjs index 8965ba23..77642022 100644 --- a/web/astro.config.mjs +++ b/web/astro.config.mjs @@ -27,6 +27,7 @@ export default defineConfig({ }, components: { // Override some default components + PageTitle: './src/overrides/PageTitle.astro', Pagination: './src/overrides/Pagination.astro', }, customCss: [ './src/styles/custom.css' ], diff --git a/web/src/overrides/PageTitle.astro b/web/src/overrides/PageTitle.astro new file mode 100644 index 00000000..4ee4178d --- /dev/null +++ b/web/src/overrides/PageTitle.astro @@ -0,0 +1,97 @@ +--- +import { functionTypePrettyName } from '@src/utils/functions'; +--- +
+

{Astro.props.entry.data.title}

+ +
{functionTypePrettyName['client']}
+
{functionTypePrettyName['server']}
+
{functionTypePrettyName['shared']}
+
+ + + + diff --git a/web/src/pages/[func].astro b/web/src/pages/[func].astro index e4efce4c..6f3348a3 100644 --- a/web/src/pages/[func].astro +++ b/web/src/pages/[func].astro @@ -36,27 +36,27 @@ if ( funcExamples.length > 0 ){ } }); } ---- - - -

Type: {funcTypePretty}

- - {funcPair && ( -

Pair: { funcPair }

- )} - - - - {funcExamples.length > 0 && funcExamples.map((example: any) => ( -
-

- -
- ))} +--- -
+
+ + {funcPair && ( +

Pair: { funcPair }

+ )} + + + + + {funcExamples.length > 0 && funcExamples.map((example: any) => ( +
+

+ +
+ ))} +
+
\ No newline at end of file diff --git a/web/src/styles/custom.css b/web/src/styles/custom.css index 737f4dd0..3df973cb 100644 --- a/web/src/styles/custom.css +++ b/web/src/styles/custom.css @@ -1,12 +1,20 @@ /* Custom MTA Wiki CSS */ +:root { + --color-type-shared: rgba(117, 117, 255, 1); + --color-type-shared-background: rgba(117, 117, 255, 0.05); + --color-type-client: rgba(255, 50, 50, 1); + --color-type-client-background: rgba(255, 50, 50, 0.05); + --color-type-server: rgba(232, 115, 0, 1); + --color-type-server-background: rgba(232, 115, 0, 0.05); +} /* Styling for "Client-side / Server-side / Shared" */ .side-shared { - color: rgb(117, 117, 255); + color: var(--color-type-shared); } .side-client { - color: rgb(255, 50, 50); + color: var(--color-type-client); } .side-server { - color: rgb(232, 115, 0); + color: var(--color-type-server); } diff --git a/web/src/utils/functions.ts b/web/src/utils/functions.ts index 0ed9c837..b75c7151 100644 --- a/web/src/utils/functions.ts +++ b/web/src/utils/functions.ts @@ -1,6 +1,8 @@ import { getCollection } from 'astro:content'; import path from 'path'; +import type { FunctionType } from './types'; + type FunctionItem = Awaited>[number]; type FunctionsByCategory = { @@ -18,16 +20,20 @@ export type FunctionData = { server?: any; }; -function getFunctionType(data: FunctionData): 'shared' | 'client' | 'server' { +export const functionTypePrettyName = { + 'client': 'Client-side', + 'server': 'Server-side', + 'shared': 'Shared', +}; + +function getFunctionType(data: FunctionData): FunctionType { if (data.shared) return 'shared'; if (data.client) return 'client'; return 'server'; } function getFunctionTypePretty(data: FunctionData): string { const funcType = getFunctionType(data); - if (funcType === 'shared') return 'Shared'; - if (funcType === 'client') return 'Client-side'; - return 'Server-side'; + return functionTypePrettyName[funcType] ?? 'Server-side'; } export function getFunctionInfo(data: FunctionData): any { diff --git a/web/src/utils/types.ts b/web/src/utils/types.ts new file mode 100644 index 00000000..0fc79202 --- /dev/null +++ b/web/src/utils/types.ts @@ -0,0 +1 @@ +export type FunctionType = 'shared' | 'client' | 'server'; \ No newline at end of file