feat(rss-feed): add optional poster (#5452)
This commit is contained in:
1 parent
faffb818f9
commit
6ec058c835
5 files changed
+33
-17
No files matched your search
@@ -208,6 +208,7 @@ async function setupUrlRestrictionAsync(dbUrls: string[]) {
|
|||||||
hideDescription: false,
|
hideDescription: false,
|
||||||
textLinesClamp: 3,
|
textLinesClamp: 3,
|
||||||
maximumAmountPosts: 5,
|
maximumAmountPosts: 5,
|
||||||
|
showPosterImage: true,
|
||||||
} satisfies WidgetComponentProps<"rssFeed">["options"]),
|
} satisfies WidgetComponentProps<"rssFeed">["options"]),
|
||||||
}) satisfies InferInsertModel<typeof items>,
|
}) satisfies InferInsertModel<typeof items>,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ const optionMapping: OptionMapping = {
|
|||||||
maximumAmountPosts: (oldOptions) => oldOptions.maximumAmountOfPosts,
|
maximumAmountPosts: (oldOptions) => oldOptions.maximumAmountOfPosts,
|
||||||
textLinesClamp: (oldOptions) => oldOptions.textLinesClamp,
|
textLinesClamp: (oldOptions) => oldOptions.textLinesClamp,
|
||||||
hideDescription: () => undefined,
|
hideDescription: () => undefined,
|
||||||
|
showPosterImage: () => true, // This was the default in oldmarr
|
||||||
},
|
},
|
||||||
notebook: {
|
notebook: {
|
||||||
allowReadOnlyCheck: (oldOptions) => oldOptions.allowReadOnlyCheck,
|
allowReadOnlyCheck: (oldOptions) => oldOptions.allowReadOnlyCheck,
|
||||||
|
|||||||
@@ -2516,6 +2516,9 @@
|
|||||||
},
|
},
|
||||||
"hideDescription": {
|
"hideDescription": {
|
||||||
"label": "Hide description"
|
"label": "Hide description"
|
||||||
|
},
|
||||||
|
"showPosterImage": {
|
||||||
|
"label": "Show poster image"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ const useLiveFeedEntries = (input: RouterInputs["widget"]["rssFeed"]["getFeeds"]
|
|||||||
return feedEntries;
|
return feedEntries;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RssFeed({ options }: WidgetComponentProps<"rssFeed">) {
|
export default function RssFeed({ options, width }: WidgetComponentProps<"rssFeed">) {
|
||||||
const feedEntries = useLiveFeedEntries({
|
const feedEntries = useLiveFeedEntries({
|
||||||
urls: options.feedUrls,
|
urls: options.feedUrls,
|
||||||
maximumAmountPosts: typeof options.maximumAmountPosts === "number" ? options.maximumAmountPosts : 100,
|
maximumAmountPosts: typeof options.maximumAmountPosts === "number" ? options.maximumAmountPosts : 100,
|
||||||
@@ -49,6 +49,8 @@ export default function RssFeed({ options }: WidgetComponentProps<"rssFeed">) {
|
|||||||
|
|
||||||
const languageDir = options.enableRtl ? "RTL" : "LTR";
|
const languageDir = options.enableRtl ? "RTL" : "LTR";
|
||||||
|
|
||||||
|
const isNarrow = width < 128 * 3;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollArea className="scroll-area-w100" w="100%" p="sm">
|
<ScrollArea className="scroll-area-w100" w="100%" p="sm">
|
||||||
<Stack w={"100%"} gap="sm">
|
<Stack w={"100%"} gap="sm">
|
||||||
@@ -63,27 +65,33 @@ export default function RssFeed({ options }: WidgetComponentProps<"rssFeed">) {
|
|||||||
w="100%"
|
w="100%"
|
||||||
p="sm"
|
p="sm"
|
||||||
>
|
>
|
||||||
{feedEntry.enclosure && (
|
{feedEntry.enclosure !== undefined && (
|
||||||
<Image className={classes.backgroundImage} src={feedEntry.enclosure} alt="backdrop" />
|
<Image className={classes.backgroundImage} src={feedEntry.enclosure} alt="backdrop" />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Flex gap="sm" direction="column" w="100%">
|
<Group wrap="nowrap">
|
||||||
<Text dir={languageDir} fz="sm" lh="sm" lineClamp={2}>
|
{feedEntry.enclosure !== undefined && options.showPosterImage && !isNarrow && (
|
||||||
{feedEntry.title}
|
<Image src={feedEntry.enclosure} alt={feedEntry.title} w={140} h={140} radius="sm" />
|
||||||
</Text>
|
|
||||||
{!options.hideDescription && feedEntry.description && (
|
|
||||||
<Text
|
|
||||||
className={feedEntry.description}
|
|
||||||
dir={languageDir}
|
|
||||||
c="dimmed"
|
|
||||||
size="sm"
|
|
||||||
lineClamp={options.textLinesClamp}
|
|
||||||
dangerouslySetInnerHTML={{ __html: feedEntry.description }}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{feedEntry.published && <InfoDisplay date={dayjs(feedEntry.published).fromNow()} />}
|
<Flex gap="sm" direction="column" w="100%">
|
||||||
</Flex>
|
<Text dir={languageDir} fz="sm" lh="sm" lineClamp={2}>
|
||||||
|
{feedEntry.title}
|
||||||
|
</Text>
|
||||||
|
{!options.hideDescription && feedEntry.description && (
|
||||||
|
<Text
|
||||||
|
className={feedEntry.description}
|
||||||
|
dir={languageDir}
|
||||||
|
c="dimmed"
|
||||||
|
size="sm"
|
||||||
|
lineClamp={options.textLinesClamp}
|
||||||
|
dangerouslySetInnerHTML={{ __html: feedEntry.description }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{feedEntry.published && <InfoDisplay date={dayjs(feedEntry.published).fromNow()} />}
|
||||||
|
</Flex>
|
||||||
|
</Group>
|
||||||
</Card>
|
</Card>
|
||||||
))}
|
))}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ export const { definition, componentLoader } = createWidgetDefinition("rssFeed",
|
|||||||
hideDescription: factory.switch({
|
hideDescription: factory.switch({
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
}),
|
}),
|
||||||
|
showPosterImage: factory.switch({
|
||||||
|
defaultValue: false,
|
||||||
|
}),
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
}).withDynamicImport(() => import("./component"));
|
}).withDynamicImport(() => import("./component"));
|
||||||
Reference in new issue
Block a user