From ade3442b71fefa71672784b397045806f4ad0626 Mon Sep 17 00:00:00 2001 From: kxndrick0 Date: Thu, 20 Feb 2025 18:27:39 -0600 Subject: [PATCH 1/4] code visualization --- web/src/pages/[func].astro | 26 +++++++++++++++++++++++++- web/src/utils/functions.ts | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/web/src/pages/[func].astro b/web/src/pages/[func].astro index b155956..e4efce4 100644 --- a/web/src/pages/[func].astro +++ b/web/src/pages/[func].astro @@ -3,6 +3,9 @@ import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro'; import { getCollection } from 'astro:content'; import { getFunctionInfo } from '@src/utils/functions'; import { marked } from 'marked'; +import fs from "fs"; +import path from "path"; +import { Code } from '@astrojs/starlight/components'; export async function getStaticPaths() { const functions = await getCollection('functions'); @@ -15,11 +18,24 @@ export async function getStaticPaths() { const { func } = Astro.props; const funcInfo = getFunctionInfo(func.data); - const funcType = funcInfo.type; const funcTypePretty = funcInfo.typePretty; const funcPair = funcInfo.pair; +const funcPath = path.dirname(func.filePath ?? "") +let funcExamples = funcInfo.examples + +if ( funcExamples.length > 0 ){ + funcExamples = funcInfo.examples.map((example: any) => { + try { + const luaCode = fs.readFileSync(path.resolve(`${funcPath}`, example.path), "utf8"); + return { ...example, luaCode }; + } catch (error) { + console.error(`Error reading ${example.path}:`, error); + return { ...example, luaCode: "Loading example error." }; + } + }); +} --- + + {funcExamples.length > 0 && funcExamples.map((example: any) => ( +
+

+ +
+ ))} +
diff --git a/web/src/utils/functions.ts b/web/src/utils/functions.ts index f084c28..0ed9c83 100644 --- a/web/src/utils/functions.ts +++ b/web/src/utils/functions.ts @@ -36,6 +36,7 @@ export function getFunctionInfo(data: FunctionData): any { type: getFunctionType(data), typePretty: getFunctionTypePretty(data), pair: data.shared?.pair || data.client?.pair || data.server?.pair || false, + examples: data.shared?.examples || data.client?.examples || data.server?.examples || [ ], }; } From ccde14ffea45979e52739814ac2e27a4951241b1 Mon Sep 17 00:00:00 2001 From: kxndrick0 Date: Sat, 22 Feb 2025 02:17:52 -0600 Subject: [PATCH 2/4] add more pagination buttons --- web/src/overrides/Pagination.astro | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/web/src/overrides/Pagination.astro b/web/src/overrides/Pagination.astro index ea34f99..f49dd37 100644 --- a/web/src/overrides/Pagination.astro +++ b/web/src/overrides/Pagination.astro @@ -15,9 +15,26 @@ import IconLinkCard from '@src/components/IconLinkCard.astro'; title="Forum" description="Engage with the community in the old-fashioned way." href="https://forum.multitheftauto.com/" /> - + + + + + + Date: Sat, 22 Feb 2025 02:31:20 -0600 Subject: [PATCH 3/4] fix tab --- web/src/overrides/Pagination.astro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/overrides/Pagination.astro b/web/src/overrides/Pagination.astro index f49dd37..b3f017b 100644 --- a/web/src/overrides/Pagination.astro +++ b/web/src/overrides/Pagination.astro @@ -16,7 +16,7 @@ import IconLinkCard from '@src/components/IconLinkCard.astro'; description="Engage with the community in the old-fashioned way." href="https://forum.multitheftauto.com/" /> - Date: Sun, 23 Feb 2025 18:17:56 -0600 Subject: [PATCH 4/4] re-organized buttons and add colors --- web/src/components/IconLinkCard.astro | 10 +++++---- web/src/overrides/Pagination.astro | 30 +++++++++++++++------------ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/web/src/components/IconLinkCard.astro b/web/src/components/IconLinkCard.astro index 1837d85..b9f0949 100644 --- a/web/src/components/IconLinkCard.astro +++ b/web/src/components/IconLinkCard.astro @@ -11,17 +11,19 @@ interface Props extends Omit, 'title'> { title: string; description?: string; icon?: StarlightIcon; + iconColor?: string; + titleColor?: string; } -const { title, description, icon, target = Astro.props.target || '_blank', ...attributes } = Astro.props; +const { title, description, icon, iconColor, titleColor, target = Astro.props.target || '_blank', ...attributes } = Astro.props; ---