diff --git a/web/src/overrides/Pagination.astro b/web/src/overrides/Pagination.astro index ea34f999..b3f017b7 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/" /> - + + + + + + 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 f084c281..0ed9c837 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 || [ ], }; }