Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/components/modules/Accordion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
class="overflow-hidden data-[state=open]:animate-slideDown data-[state=closed]:animate-slideUp"
>
<div class="pb-4 type-body">
<RichTextRenderer :json="item.copy?.json" />
<RichTextRenderer
:json="item.copy?.json"
:assets="getEmbeddedAssets(item.copy?.links)"
/>
</div>
</AccordionContent>
</AccordionItem>
Expand Down
9 changes: 2 additions & 7 deletions app/components/modules/CenterText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,12 @@
</template>

<script setup lang="ts">
import type { EmbeddedAsset } from "~/components/render/RichTextRenderer.vue";
import type { ModuleProps } from "~/types/module";
import type { CenterTextFragment } from "~~/shared/types/graphql";

const { data } = defineProps<ModuleProps<CenterTextFragment>>();

const embeddedAssets = computed((): EmbeddedAsset[] => {
const blockAssets = data?.text?.links?.assets?.block;
if (!blockAssets?.length) return [];
return blockAssets.filter(
(asset): asset is EmbeddedAsset => asset !== null && asset.sys?.id != null,
);
const embeddedAssets = computed(() => {
return getEmbeddedAssets(data?.text?.links);
});
</script>
10 changes: 10 additions & 0 deletions app/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { EmbeddedAsset } from "~/components/render/RichTextRenderer.vue";
import type { Pagination } from "~~/shared/types/Pagination";

export const ariaCurrent = (route: string, currentRoute: string) => {
Expand Down Expand Up @@ -36,3 +37,12 @@ export const formatRelationshipType = (type: string) => {
return type;
}
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const getEmbeddedAssets = (links: any): EmbeddedAsset[] => {
const blockAssets = (links?.assets?.block ?? []) as (EmbeddedAsset | null)[];
if (!blockAssets?.length) return [];
return blockAssets.filter(
(asset): asset is EmbeddedAsset => asset !== null && asset.sys?.id != null,
);
Comment thread
ben-basten marked this conversation as resolved.
};
10 changes: 10 additions & 0 deletions server/graphql/fragments/title-copy.fragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ export const TITLE_COPY_FRAGMENT = gql`
title
copy {
json
links {
assets {
block {
sys {
id
}
...Image
}
}
}
}
}
`;
Loading