Skip to content

Commit a08da9e

Browse files
Add preview images for functions/events/elements
1 parent d48b9c5 commit a08da9e

File tree

9 files changed

+49
-1
lines changed

9 files changed

+49
-1
lines changed

functions/Cursor/getCursorAlpha.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ client:
55
This function is used to get the client's cursor alpha (transparency).
66
preview_images:
77
- path: 'cursor-alpha.jpg'
8+
width: 160
89
description: 'Visual representation of the cursor alpha:'
910
returns:
1011
description: |

schemas/common-defs.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ $defs:
6666
description:
6767
type: string
6868
description: Brief summary of the content in the picture.
69+
width:
70+
type: integer
71+
description: Width of the image in pixels.
72+
height:
73+
type: integer
74+
description: Height of the image in pixels.
6975

7076
version:
7177
type: object

schemas/element.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ properties:
1717
description: A list of noteworthy pieces of information for the item.
1818
items:
1919
type: string
20+
preview_images:
21+
$ref: 'common-defs.yaml#/$defs/preview_images'
2022
examples:
2123
$ref: 'common-defs.yaml#/$defs/examples'
2224
see_also:
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
import { Image } from 'astro:assets';
3+
import { getAssetImagePath } from '@src/utils/general';
4+
5+
6+
interface Props {
7+
images?: any;
8+
}
9+
10+
const { images } = Astro.props;
11+
---
12+
13+
{images && images.length > 0 && (
14+
<div class="preview-images">
15+
{images.map((imageInfo: any) => (
16+
<Image width={imageInfo.width || undefined}
17+
height={imageInfo.height || undefined}
18+
src={getAssetImagePath(imageInfo.path)}
19+
alt={imageInfo.description || "Preview"} />
20+
))}
21+
</div>
22+
)}

web/src/pages/[element].astro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import path from "path";
66
import { getSeeAlsoLinksForItem } from '@src/utils/general';
77
import { getElementCategory, getOOPFunctionsForElement } from '@src/utils/elements';
88
9+
import PreviewImages from '@src/components/PreviewImages.astro';
910
import SeeAlsoSection from '@src/components/SeeAlsoSection.astro';
1011
import CodeExamplesSection from '@src/components/CodeExamplesSection.astro';
1112
import ElementOOPInfo from '@src/components/ElementOOPInfo.astro';
@@ -47,6 +48,8 @@ let oop_compatible_functions = getOOPFunctionsForElement(element.data.name);
4748

4849
<EnhancedMarkdown content={element.data.description} />
4950

51+
<PreviewImages images={element.data.preview_images} />
52+
5053
<ElementOOPInfo
5154
element_name={element.data.name}
5255
oop_only_methods={oop_only_methods}

web/src/pages/[event].astro

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ import path from "path";
66
import { Code } from '@astrojs/starlight/components';
77
import { getSeeAlsoLinksForItem } from '@src/utils/general';
88
9+
910
import NoteBox from '@src/components/NoteBox.astro';
1011
import type { NotesType } from '@src/utils/types';
1112
1213
import SeeAlsoSection from '@src/components/SeeAlsoSection.astro';
1314
import CodeExamplesSection from '@src/components/CodeExamplesSection.astro';
1415
import ItemDescription from '@src/components/ItemDescription.astro';
1516
import EnhancedMarkdown from '@src/components/EnhancedMarkdown.astro';
17+
import PreviewImages from '@src/components/PreviewImages.astro';
1618
1719
export async function getStaticPaths() {
1820
const events = await getCollection('events');
@@ -73,6 +75,9 @@ if (Array.isArray(event.data.notes) && event.data.notes.length > 0) {
7375
<!-- Description -->
7476
<ItemDescription description={event.data.description} />
7577

78+
<!-- Preview Images -->
79+
<PreviewImages images={event.data.preview_images} />
80+
7681
<!-- Notes -->
7782
{notesContent.length > 0 && (
7883
<div class="notes-section">

web/src/pages/[func].astro

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import CodeExamplesSection from '@src/components/CodeExamplesSection.astro';
1616
import ChangelogList from '@src/components/ChangelogList.astro';
1717
import ItemDescription from '@src/components/ItemDescription.astro';
1818
import EnhancedMarkdown from '@src/components/EnhancedMarkdown.astro';
19+
import PreviewImages from '@src/components/PreviewImages.astro';
1920
2021
export async function getStaticPaths() {
2122
const functions = await getCollection('functions');
@@ -74,7 +75,6 @@ const metaArray = func.data[funcInfo.type]?.meta ?? [];
7475
const changelogEntries = metaArray.find(m => m.changelog)?.changelog ?? [];
7576
7677
let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
77-
7878
---
7979

8080
<div class={"show-type-badge-" + funcType}>
@@ -91,6 +91,9 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
9191
<!-- Description -->
9292
<ItemDescription description={funcInfo.description} />
9393

94+
<!-- Preview Images -->
95+
<PreviewImages images={funcInfo.preview_images} />
96+
9497
<!-- Notes -->
9598
{notesContent.length > 0 && (
9699
<div class="notes-section">

web/src/styles/custom.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
margin-top: 1.5rem;
2626
margin-bottom: 1.5rem;
2727
}
28+
.preview-images {
29+
display: flex;
30+
flex-wrap: wrap;
31+
gap: 1rem;
32+
}
2833

2934
.see-also-section {
3035
margin-top: 4rem;

web/src/utils/functions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export type FunctionInfo = {
3131
type: FunctionType;
3232
typePretty: string;
3333
pair?: string;
34+
preview_images?: string[];
3435
oop?: OOPInfo;
3536
notes?: NotesType;
3637
};

0 commit comments

Comments
 (0)