@@ -18,17 +18,14 @@ import { ScalingIframe } from "@components/ScalingIframe";
18
18
interface Props {
19
19
sketchId: string ;
20
20
authorName: string ;
21
- title: string ;
22
21
}
23
22
24
- const { sketchId, authorName, title } = Astro .props ;
25
- const sketchInfo = await getSketch (sketchId );
23
+ const { sketchId, authorName } = Astro .props ;
24
+ const { title, createdOn, instructions } = await getSketch (sketchId );
26
25
27
26
const currentLocale = getCurrentLocale (Astro .url .pathname );
28
27
const t = await getUiTranslator (currentLocale );
29
- const dateString = new Date (sketchInfo .createdOn ).toLocaleDateString (
30
- currentLocale ,
31
- {
28
+ const dateString = new Date (createdOn ).toLocaleDateString (currentLocale , {
32
29
year: " numeric" ,
33
30
month: " long" ,
34
31
day: " numeric" ,
@@ -37,12 +34,12 @@ const dateString = new Date(sketchInfo.createdOn).toLocaleDateString(
37
34
38
35
setJumpToState (null );
39
36
const moreSketches = await getRandomCurationSketches (4 );
40
- const featuredImageURL = makeThumbnailUrl (sketchInfo . visualID );
37
+ const featuredImageURL = makeThumbnailUrl (sketchId );
41
38
42
39
// NOTE: Commenting out the call to getSketchSize to minimise calls to OP due to rate limiting
43
40
// width and height should be moved to data fetched by either getCuratedSketches or getSketch to minimise calls.
44
41
45
- // let { width, height } = await getSketchSize(sketchInfo.visualID );
42
+ // let { width, height } = await getSketchSize(sketchId );
46
43
// let heightOverWidth = 1 / 1.5;
47
44
// if (width && height) {
48
45
// // Account for OP header bar
@@ -61,7 +58,7 @@ const iframeTitle = `OpenProcessing Sketch: ${title} by ${authorName}`;
61
58
title ={ title }
62
59
locale ={ currentLocale }
63
60
featuredImageSrc ={ featuredImageURL }
64
- description ={ sketchInfo . instructions }
61
+ description ={ instructions }
65
62
/>
66
63
67
64
<BaseLayout
@@ -83,14 +80,14 @@ const iframeTitle = `OpenProcessing Sketch: ${title} by ${authorName}`;
83
80
width ? (
84
81
<ScalingIframe
85
82
client :load
86
- src = { makeSketchEmbedUrl (sketchInfo . visualID )}
83
+ src = { makeSketchEmbedUrl (sketchId )}
87
84
width = { width }
88
85
height = { height }
89
86
title = { iframeTitle }
90
87
/>
91
88
) : (
92
89
<iframe
93
- src = { makeSketchEmbedUrl (sketchInfo . visualID )}
90
+ src = { makeSketchEmbedUrl (sketchId )}
94
91
width = " 100%"
95
92
height = " 100%"
96
93
style = { {
@@ -108,7 +105,7 @@ const iframeTitle = `OpenProcessing Sketch: ${title} by ${authorName}`;
108
105
<div class =" py-md grid gap-y-sm md:gap-y-md" >
109
106
<LinkButton
110
107
variant =" code"
111
- url ={ ` ${makeSketchLinkUrl (sketchInfo . visualID )}/#code ` }
108
+ url ={ ` ${makeSketchLinkUrl (sketchId )}/#code ` }
112
109
class =" min-w-[184px] lg:min-w-[220px]" >{ t (" Show Code" )} </LinkButton
113
110
>
114
111
<LinkButton
@@ -118,16 +115,11 @@ const iframeTitle = `OpenProcessing Sketch: ${title} by ${authorName}`;
118
115
>
119
116
</div >
120
117
121
- {
122
- sketchInfo .instructions && (
123
- <p class = " text-md my-sm md:my-lg" >{ sketchInfo .instructions } </p >
124
- )
125
- }
118
+ { instructions && <p class = " text-md my-sm md:my-lg" >{ instructions } </p >}
126
119
127
120
<p class =" text-xs md:text-base mb-3xl" >
128
- This <a
129
- class =" text-type-magenta"
130
- href ={ makeSketchLinkUrl (sketchInfo .visualID )} >sketch</a
121
+ This <a class =" text-type-magenta" href ={ makeSketchLinkUrl (sketchId )}
122
+ >sketch</a
131
123
> is ported from the <a
132
124
class =" text-type-magenta"
133
125
href =" https://openprocessing.org" >OpenProcessing</a
0 commit comments