generated from tpl/obsidian-sample-plugin
Just use page count for book width
This commit is contained in:
parent
b9f146f922
commit
94fe4d5f1c
|
@ -84,8 +84,6 @@
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
const calculateWidth = (pageCount: number) =>
|
||||
Math.max(10, Math.min(1000, 200 + pageCount * 10));
|
||||
|
||||
function getBookData(metadata: FileMetadata): BookData {
|
||||
return {
|
||||
|
@ -94,9 +92,9 @@
|
|||
? metadata.frontmatter[settings.subtitleProperty]
|
||||
: undefined,
|
||||
author: metadata.frontmatter[settings.authorsProperty].join(", "),
|
||||
width: calculateWidth(
|
||||
metadata.frontmatter[settingsStore.settings.pageCountProperty],
|
||||
),
|
||||
width: metadata.frontmatter[
|
||||
settingsStore.settings.pageCountProperty
|
||||
],
|
||||
color: randomColor(),
|
||||
design: randomDesign(),
|
||||
orientation: randomOrientation(),
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
onClick,
|
||||
}: BookProps = $props();
|
||||
|
||||
function widthCheck(input: number | undefined) {
|
||||
function normalizeWidth(input: number | undefined) {
|
||||
if (input) {
|
||||
if (input <= 150) {
|
||||
return BOOK_SIZE_MIN;
|
||||
|
@ -57,7 +57,7 @@
|
|||
: Color.fromCSSColor(colorRaw),
|
||||
);
|
||||
|
||||
const verifiedWidth = $derived(widthCheck(width));
|
||||
const verifiedWidth = $derived(normalizeWidth(width));
|
||||
</script>
|
||||
|
||||
{#if orientation}
|
||||
|
|
Loading…
Reference in New Issue