Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | <script lang="ts">
import { getContext, setContext } from "svelte";
import { error } from "@sveltejs/kit";
import { isDocument } from "$lib/components/ContentfulRichText/predicates";
import { key as pageMetadataMapKey } from "$lib/context/pageMetadataMap";
import Node from "./nodes/Node.svelte";
import type { Document } from "@contentful/rich-text-types";
import type { Links } from "./types";
import type { PageMetadataMap } from "$lib/loadPageMetadataMap";
import {
linksKey,
createLinksContext,
blurhashesKey,
type LinksContext,
imageSizeTypeKey,
} from "./context";
import type { SizeType } from "$lib/constants/images";
export let document: Document;
export let links: Links | undefined = undefined;
$: pageMetadataMap = getContext<PageMetadataMap>(pageMetadataMapKey);
$: setContext<LinksContext | undefined>(
linksKey,
links ? createLinksContext(links, pageMetadataMap) : links,
);
export let blurhashes: Record<string, string> | null | undefined = undefined;
$: setContext<Record<string, string> | null | undefined>(blurhashesKey, blurhashes);
export let imageSizeType: SizeType = "col-12";
$: setContext<string>(imageSizeTypeKey, imageSizeType);
$: if (!isDocument(document)) {
error(500, {
title: "We could not render this page.",
message: "Contentful connection failed and fallback document does not match expected format.",
});
}
</script>
{#key document}
{#each document.content as subNode}
<Node node={subNode} />
{/each}
{/key}
|