dptxa-proxy / src /components /DeferredSection.astro
TXAVLOG
Deploy DPTXA to Hugging Face Spaces
4bea261
Raw
History Blame Contribute Delete
740 Bytes
---
import MovieSection from './MovieSection.jsx';
import { getNewestMovies, getSeriesMovies, getSingleMovies, getCartoonMovies } from '../lib/api.js';
interface Props {
type: 'newest' | 'series' | 'single' | 'cartoon';
title: string;
href: string;
}
const { type, title, href } = Astro.props;
let movies = [];
try {
if (type === 'newest') movies = (await getNewestMovies(1))?.items || [];
if (type === 'series') movies = (await getSeriesMovies(1))?.items || [];
if (type === 'single') movies = (await getSingleMovies(1))?.items || [];
if (type === 'cartoon') movies = (await getCartoonMovies(1))?.items || [];
} catch (e) {
console.error(e);
}
---
<MovieSection title={title} movies={movies} href={href} client:load />