Files
RSSHub/lib/routes/transcriptforest/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

45 lines
1.1 KiB
TypeScript

import { renderToString } from 'hono/jsx/dom/server';
type AudioData = {
src?: string;
type?: string;
};
type TextData = {
startTime?: string;
endTime?: string;
text?: string;
};
type DescriptionData = {
audios?: AudioData[];
texts?: TextData[];
};
const TranscriptForestDescription = ({ audios, texts }: DescriptionData) => (
<>
{audios?.map((audio) =>
audio?.src ? (
<audio controls>
<source src={audio.src} type={audio.type} />
<object data={audio.src}>
<embed src={audio.src} />
</object>
</audio>
) : null
)}
{texts?.map((text) => (
<>
{text.startTime && text.endTime ? (
<small>
{text.startTime} - {text.endTime}
</small>
) : null}
<p>{text.text}</p>
</>
))}
</>
);
export const renderDescription = (data: DescriptionData) => renderToString(<TranscriptForestDescription {...data} />);