@@ -18,17 +18,14 @@ import { ScalingIframe } from "@components/ScalingIframe";
1818interface Props {
1919 sketchId: string ;
2020 authorName: string ;
21- title: string ;
2221}
2322
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 );
2625
2726const currentLocale = getCurrentLocale (Astro .url .pathname );
2827const t = await getUiTranslator (currentLocale );
29- const dateString = new Date (sketchInfo .createdOn ).toLocaleDateString (
30- currentLocale ,
31- {
28+ const dateString = new Date (createdOn ).toLocaleDateString (currentLocale , {
3229 year: " numeric" ,
3330 month: " long" ,
3431 day: " numeric" ,
@@ -37,12 +34,12 @@ const dateString = new Date(sketchInfo.createdOn).toLocaleDateString(
3734
3835setJumpToState (null );
3936const moreSketches = await getRandomCurationSketches (4 );
40- const featuredImageURL = makeThumbnailUrl (sketchInfo . visualID );
37+ const featuredImageURL = makeThumbnailUrl (sketchId );
4138
4239// NOTE: Commenting out the call to getSketchSize to minimise calls to OP due to rate limiting
4340// width and height should be moved to data fetched by either getCuratedSketches or getSketch to minimise calls.
4441
45- // let { width, height } = await getSketchSize(sketchInfo.visualID );
42+ // let { width, height } = await getSketchSize(sketchId );
4643// let heightOverWidth = 1 / 1.5;
4744// if (width && height) {
4845// // Account for OP header bar
@@ -61,7 +58,7 @@ const iframeTitle = `OpenProcessing Sketch: ${title} by ${authorName}`;
6158 title ={ title }
6259 locale ={ currentLocale }
6360 featuredImageSrc ={ featuredImageURL }
64- description ={ sketchInfo . instructions }
61+ description ={ instructions }
6562/>
6663
6764<BaseLayout
@@ -83,14 +80,14 @@ const iframeTitle = `OpenProcessing Sketch: ${title} by ${authorName}`;
8380 width ? (
8481 <ScalingIframe
8582 client :load
86- src = { makeSketchEmbedUrl (sketchInfo . visualID )}
83+ src = { makeSketchEmbedUrl (sketchId )}
8784 width = { width }
8885 height = { height }
8986 title = { iframeTitle }
9087 />
9188 ) : (
9289 <iframe
93- src = { makeSketchEmbedUrl (sketchInfo . visualID )}
90+ src = { makeSketchEmbedUrl (sketchId )}
9491 width = " 100%"
9592 height = " 100%"
9693 style = { {
@@ -108,7 +105,7 @@ const iframeTitle = `OpenProcessing Sketch: ${title} by ${authorName}`;
108105 <div class =" py-md grid gap-y-sm md:gap-y-md" >
109106 <LinkButton
110107 variant =" code"
111- url ={ ` ${makeSketchLinkUrl (sketchInfo . visualID )}/#code ` }
108+ url ={ ` ${makeSketchLinkUrl (sketchId )}/#code ` }
112109 class =" min-w-[184px] lg:min-w-[220px]" >{ t (" Show Code" )} </LinkButton
113110 >
114111 <LinkButton
@@ -118,16 +115,11 @@ const iframeTitle = `OpenProcessing Sketch: ${title} by ${authorName}`;
118115 >
119116 </div >
120117
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 >}
126119
127120 <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
131123 > is ported from the <a
132124 class =" text-type-magenta"
133125 href =" https://openprocessing.org" >OpenProcessing</a
0 commit comments