Release 0.5.1
This commit is contained in:
1 parent
5a9d7735d4
commit
fb24d171ae
36 files changed
+5099
-263
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { requireUser } from '#lib/server/auth.js';
|
||||
import { getPiece } from '#lib/server/content.js';
|
||||
import { renderMarkdown } from '#lib/server/markdown.js';
|
||||
import { buildEmbedUrl, type PresentationContent } from '#lib/server/presentation.js';
|
||||
|
||||
export const load: PageServerLoad = ({ locals, params }) => {
|
||||
requireUser(locals.user);
|
||||
const piece = getPiece(params.id);
|
||||
if (!piece) error(404, 'Piece nicht gefunden');
|
||||
const source =
|
||||
piece.presentationSourcePosition === null
|
||||
? null
|
||||
: (piece.sources[piece.presentationSourcePosition] ?? null);
|
||||
const content: PresentationContent & {
|
||||
sources: typeof piece.sources;
|
||||
images: { id: string; altText: string }[];
|
||||
} = {
|
||||
mode: piece.presentationMode,
|
||||
title: piece.title,
|
||||
html: renderMarkdown(piece.presentationText),
|
||||
source,
|
||||
previewTitle: piece.presentationTitle,
|
||||
description: piece.presentationDescription,
|
||||
imageUrl: piece.presentationImageUrl,
|
||||
siteName: piece.presentationSiteName,
|
||||
provider:
|
||||
piece.presentationProvider === 'youtube' || piece.presentationProvider === 'tiktok'
|
||||
? piece.presentationProvider
|
||||
: '',
|
||||
providerId: piece.presentationProviderId,
|
||||
embedUrl: buildEmbedUrl(
|
||||
piece.presentationProvider === 'youtube' || piece.presentationProvider === 'tiktok'
|
||||
? piece.presentationProvider
|
||||
: '',
|
||||
piece.presentationProviderId,
|
||||
source?.timecodeSeconds ?? null
|
||||
),
|
||||
sources: piece.sources,
|
||||
images: piece.media.map((item) => ({ id: item.id, altText: item.altText }))
|
||||
};
|
||||
return { pieceId: piece.id, content };
|
||||
};
|
||||
Reference in new issue
Block a user