Files
RSSHub/lib/routes/deeplearning/templates/description.tsx
T
DIYgod cf4e772de8 refactor: replace art template with jsx (#20777)
* refactor: replace art template with jsx

* fix: tsx files

* fix: renderToString import

* fix: hono html raw import

* feat: remove art
2025-12-29 12:27:32 +08:00

30 lines
824 B
TypeScript

import { raw } from 'hono/html';
import { renderToString } from 'hono/jsx/dom/server';
type DescriptionImage = {
src?: string;
alt?: string;
};
type DescriptionProps = {
images?: DescriptionImage[];
intro?: string;
description?: string;
};
const Description = ({ images, intro, description }: DescriptionProps) => (
<>
{images?.map((image, index) =>
image?.src ? (
<figure key={`${image.src}-${index}`}>
<img src={image.src} alt={image.alt} />
</figure>
) : null
)}
{intro ? <blockquote>{intro}</blockquote> : null}
{description ? <>{raw(description)}</> : null}
</>
);
export const renderDescription = (props: DescriptionProps): string => renderToString(<Description {...props} />);