|
|
@ -1,33 +1,13 @@
|
|
|
|
<script lang="ts">
|
|
|
|
<script lang="ts">
|
|
|
|
import { formatDateRelative } from "$lib";
|
|
|
|
import { formatDateRelative } from "$lib";
|
|
|
|
import { onMount } from "svelte";
|
|
|
|
|
|
|
|
import Box from "../../../components/atoms/Box.svelte";
|
|
|
|
import Box from "../../../components/atoms/Box.svelte";
|
|
|
|
import Error from "../../../components/molecules/Error.svelte";
|
|
|
|
import Error from "../../../components/molecules/Error.svelte";
|
|
|
|
import Thumbnail from "../../../components/molecules/Thumbnail.svelte";
|
|
|
|
import Thumbnail from "../../../components/molecules/Thumbnail.svelte";
|
|
|
|
import BlogPostContent from "../../../components/organisms/BlogPostContent.svelte";
|
|
|
|
import BlogPostContent from "../../../components/organisms/BlogPostContent.svelte";
|
|
|
|
import type { PageData } from "./$types";
|
|
|
|
import type { PageData } from "./$types";
|
|
|
|
import { beforeNavigate } from "$app/navigation";
|
|
|
|
|
|
|
|
import ContainerSlim from "../../../components/atoms/ContainerSlim.svelte";
|
|
|
|
import ContainerSlim from "../../../components/atoms/ContainerSlim.svelte";
|
|
|
|
|
|
|
|
|
|
|
|
export let data: PageData;
|
|
|
|
export let data: PageData;
|
|
|
|
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
|
|
|
|
if (!data.post) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const url = new URL(window.location.href);
|
|
|
|
|
|
|
|
const lang = url.searchParams.get("lang");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (data.post.attributes.locale !== lang) {
|
|
|
|
|
|
|
|
document
|
|
|
|
|
|
|
|
.querySelector("html")
|
|
|
|
|
|
|
|
?.setAttribute("lang", data.post.attributes.locale);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
beforeNavigate(() => {
|
|
|
|
|
|
|
|
document.querySelector("html")?.setAttribute("lang", "en");
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<ContainerSlim>
|
|
|
|
<ContainerSlim>
|
|
|
@ -37,35 +17,37 @@
|
|
|
|
{@const teaserImage = data.post.attributes.teaserImage.data?.attributes}
|
|
|
|
{@const teaserImage = data.post.attributes.teaserImage.data?.attributes}
|
|
|
|
{@const collection = data.post.attributes.collection.data?.attributes}
|
|
|
|
{@const collection = data.post.attributes.collection.data?.attributes}
|
|
|
|
|
|
|
|
|
|
|
|
<div class="blog-entry-head">
|
|
|
|
<div class="blog-entry" lang={post.attributes.locale}>
|
|
|
|
<Box>
|
|
|
|
<div class="blog-entry-head">
|
|
|
|
<div class="head-text">
|
|
|
|
<Box>
|
|
|
|
<h1>{post.attributes.title}</h1>
|
|
|
|
<div class="head-text">
|
|
|
|
<h3>by {author?.name}</h3>
|
|
|
|
<h1>{post.attributes.title}</h1>
|
|
|
|
{#if collection}
|
|
|
|
<h3>by {author?.name}</h3>
|
|
|
|
<h4>
|
|
|
|
{#if collection}
|
|
|
|
in <a href={`/blog/collection/${collection.slug}`}
|
|
|
|
<h4>
|
|
|
|
>{collection?.name}</a
|
|
|
|
in <a href={`/blog/collection/${collection.slug}`}
|
|
|
|
>
|
|
|
|
>{collection?.name}</a
|
|
|
|
</h4>
|
|
|
|
>
|
|
|
|
{/if}
|
|
|
|
</h4>
|
|
|
|
<span>{formatDateRelative(post.attributes.publishedAt)}</span>
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
<span>{formatDateRelative(post.attributes.publishedAt)}</span>
|
|
|
|
{#if post.attributes.teaserImage.data}
|
|
|
|
|
|
|
|
<div class="head-thumbnail">
|
|
|
|
|
|
|
|
<Thumbnail
|
|
|
|
|
|
|
|
imageData={{
|
|
|
|
|
|
|
|
altText: teaserImage.alternativeText,
|
|
|
|
|
|
|
|
formats: Object.values(teaserImage.formats),
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
{#if post.attributes.teaserImage.data}
|
|
|
|
</Box>
|
|
|
|
<div class="head-thumbnail">
|
|
|
|
|
|
|
|
<Thumbnail
|
|
|
|
|
|
|
|
imageData={{
|
|
|
|
|
|
|
|
altText: teaserImage.alternativeText,
|
|
|
|
|
|
|
|
formats: Object.values(teaserImage.formats),
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{#each post.attributes.content as contentEntry}
|
|
|
|
|
|
|
|
<BlogPostContent content={contentEntry} />
|
|
|
|
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{#each post.attributes.content as contentEntry}
|
|
|
|
|
|
|
|
<BlogPostContent content={contentEntry} />
|
|
|
|
|
|
|
|
{/each}
|
|
|
|
|
|
|
|
{:else if !data.error}
|
|
|
|
{:else if !data.error}
|
|
|
|
<Error error={{ message: "Could not find the post" }} />
|
|
|
|
<Error error={{ message: "Could not find the post" }} />
|
|
|
|
{/if}
|
|
|
|
{/if}
|
|
|
@ -73,34 +55,34 @@
|
|
|
|
{#if data.error}
|
|
|
|
{#if data.error}
|
|
|
|
<Error error={data.error} />
|
|
|
|
<Error error={data.error} />
|
|
|
|
{/if}
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
</ContainerSlim>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
<style lang="scss">
|
|
|
|
.blog-entry-head {
|
|
|
|
.blog-entry-head {
|
|
|
|
position: relative;
|
|
|
|
position: relative;
|
|
|
|
margin: 0;
|
|
|
|
margin: 0;
|
|
|
|
margin-bottom: 1em;
|
|
|
|
margin-bottom: 1em;
|
|
|
|
background: rgba(0, 0, 0, 0.6);
|
|
|
|
background: rgba(0, 0, 0, 0.6);
|
|
|
|
border-radius: 10px;
|
|
|
|
border-radius: 10px;
|
|
|
|
|
|
|
|
|
|
|
|
.head-text {
|
|
|
|
.head-text {
|
|
|
|
width: 100%;
|
|
|
|
width: 100%;
|
|
|
|
z-index: 10;
|
|
|
|
z-index: 10;
|
|
|
|
padding: 1em;
|
|
|
|
padding: 1em;
|
|
|
|
h1 {
|
|
|
|
h1 {
|
|
|
|
margin-top: 0;
|
|
|
|
margin-top: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
&* {
|
|
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.head-thumbnail {
|
|
|
|
&* {
|
|
|
|
position: absolute;
|
|
|
|
text-align: center;
|
|
|
|
top: 0;
|
|
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
|
|
z-index: -10;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
.head-thumbnail {
|
|
|
|
</ContainerSlim>
|
|
|
|
position: absolute;
|
|
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
|
|
z-index: -10;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|