File tree Expand file tree Collapse file tree 2 files changed +56
-7
lines changed Expand file tree Collapse file tree 2 files changed +56
-7
lines changed Original file line number Diff line number Diff line change 11---
22import { Code } from ' @astrojs/starlight/components' ;
33import { marked } from ' marked' ;
4+ import NeedsExample from ' @src/components/NeedsExample.astro' ;
45
56export interface CodeExample {
67 description? : string ;
@@ -14,18 +15,21 @@ export interface Props {
1415const { codeExamples } = Astro .props ;
1516---
1617
17- { codeExamples .length > 0 && (
18- <div class = " examples-section" >
19- <h4 >Code Examples</h4 >
20- { codeExamples .map ((example ) => (
18+ <div class =" examples-section" >
19+ <h4 >Code Examples</h4 >
20+
21+ { codeExamples .length > 0 ? (
22+ codeExamples .map ((example ) => (
2123 <div class = " code-example" >
2224 { example .description && (
2325 <Fragment set :html = { marked (example .description )} />
2426 )}
2527 <Code code = { example .luaCode } lang = " lua" />
2628 </div >
27- ))}
28- </div >
29- )}
29+ ))
30+ ) : (
31+ <NeedsExample />
32+ )}
33+ </div >
3034
3135<script type =" module" src =" /mta-keyword_linker.js" ></script >
Original file line number Diff line number Diff line change 1+ ---
2+ const pathSegments = Astro .url .pathname .split (' /' ).filter (Boolean );
3+ const functionName = pathSegments [pathSegments .length - 1 ];
4+ ---
5+
6+ <div class =" missing-example-box" >
7+ <div class =" missing-example-icon" aria-hidden =" true" >
8+ <svg xmlns =" http://www.w3.org/2000/svg" width =" 36" height =" 36" fill =" currentColor" viewBox =" 0 0 24 24" >
9+ <path d =" M6 2C4.89543 2 4 2.89543 4 4V20C4 21.1046 4.89543 22 6 22H18C19.1046 22 20 21.1046 20 20V8L14 2H6ZM13 3.5L18.5 9H13V3.5Z" />
10+ </svg >
11+ </div >
12+ <div class =" missing-example-content" >
13+ <strong >Script Example Missing</strong >
14+ <p >Function <code >{ functionName } </code > needs a script example. Help out by writing one.</p >
15+ <a href =" https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/CONTRIBUTING.md" class =" guidelines-link" >Contribution guidelines</a >
16+ </div >
17+ </div >
18+
19+ <style >
20+ .missing-example-box {
21+ display: flex;
22+ align-items: center;
23+ background-color: var(--sl-color-bg-nav);
24+ border-left: 4px solid var(--sl-color-orange);
25+ padding: 1rem 1.25rem 1rem;
26+ border-radius: 8px;
27+ margin: 1.5rem 0;
28+ color: var(--sl-color-text);
29+ gap: 1rem;
30+ }
31+
32+ .missing-example-icon {
33+ color: var(--sl-color-orange);
34+ }
35+
36+ .missing-example-content
37+ {
38+ margin-top: 0;
39+ }
40+
41+ .guidelines-link {
42+ color: var(--sl-color-orange);
43+ font-weight: bold;
44+ }
45+ </style >
You can’t perform that action at this time.
0 commit comments