-
-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathHtmlBookView.svelte
More file actions
49 lines (41 loc) · 1.31 KB
/
HtmlBookView.svelte
File metadata and controls
49 lines (41 loc) · 1.31 KB
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
48
49
<!--
@component
Display an HTML Book.
-->
<script lang="ts">
import { base } from '$app/paths';
import { scriptureConfig } from '$assets/config';
interface Props {
references: {
collection: string;
book: string;
};
bodyLineHeight: number;
bodyFontSize: number;
fetch: any;
}
let { references, bodyLineHeight, bodyFontSize, fetch }: Props = $props();
let htmlBody: string = $state();
let fontSize = $derived(bodyFontSize + 'px');
let lineHeight = $derived(bodyLineHeight + '%');
$effect(() => {
loadHtml(references.collection, references.book);
});
async function loadHtml(collectionId: string, bookId: string) {
const book = scriptureConfig.bookCollections
?.find((x) => x.id === collectionId)
?.books.find((x) => x.id === bookId);
if (book) {
const result = await fetch(
`${base}/collections/${references.collection}/${book.hashedFileName ?? book.file}`
);
if (result.ok) {
htmlBody = await result.text();
}
}
}
</script>
<div class="prose" style="line-height: {lineHeight}; font-size: {fontSize};">
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
{@html htmlBody}
</div>