@@ -12,6 +12,7 @@ import EditableSketch from "@components/EditableSketch/index.astro";
1212import RelatedItems from " @components/RelatedItems/index.astro" ;
1313import OutdatedTranslationBanner from " @components/OutdatedTranslationBanner/index.astro" ;
1414import { checkTranslationBanner } from " ../utils/translationBanner" ;
15+ import { getFallbackRemixData } from " ../pages/_utils" ;
1516
1617interface Props {
1718 example: CollectionEntry <" examples" >;
@@ -45,8 +46,15 @@ const relatedReferences =
4546
4647const { Content } = await example .render ();
4748
49+ // Use the fallback function to retrieve English remix data if the current locale doesn't have any
50+ let remixData = (await getFallbackRemixData (
51+ example .id ,
52+ currentLocale ,
53+ example .data .remix
54+ )) as typeof example .data .remix ;
55+
4856// Extract the collective attribution year. If multiple provided, uses last shown.
49- const collectivelyAttributedSince = example . data . remix ?.reduce (
57+ const collectivelyAttributedSince = remixData ?.reduce (
5058 (acc : number | null , item ) => {
5159 if (item .collectivelyAttributedSince ) {
5260 return item .collectivelyAttributedSince ;
@@ -57,7 +65,7 @@ const collectivelyAttributedSince = example.data.remix?.reduce(
5765);
5866
5967// Boolean value on whether the remix history contains links to code
60- const remixHistoryHasCodeLinks = example . data . remix ?.some (
68+ const remixHistoryHasCodeLinks = remixData ?.some (
6169 (item ) => Array .isArray (item .code ) && item .code .length > 0
6270);
6371
@@ -97,7 +105,7 @@ const { showBanner, englishUrl } = checkTranslationBanner(
97105
98106 <a href ={ Astro .url .pathname } >{ example .data .title } </a >:{ " " }
99107
100- { example . data . remix ?.map ((item , i ) => {
108+ { remixData ?.map ((item , i ) => {
101109 const parts = [];
102110
103111 // Each remix entry requires at least one attribution
@@ -146,7 +154,7 @@ const { showBanner, englishUrl } = checkTranslationBanner(
146154 { remixHistoryHasCodeLinks ? (
147155 <>
148156 { t (" attribution" , " You can find the code history of these examples here" )} { " : " }
149- { example . data . remix
157+ { remixData
150158 .map (item => item ?.code )
151159 .flat ()
152160 .filter (codeItem => codeItem && codeItem .URL )
0 commit comments