Pelisgo’s TV series feature lives onDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/LuisED18/proyecto-pagina-peliculas/llms.txt
Use this file to discover all available pages before exploring further.
series.html and is powered by the exact same main.js module that drives the movies page. There is no separate script — instead, main.js inspects the current page URL at runtime and dynamically switches the TMDB endpoint and the result field names between movie and tv mode. This means all logic for fetching, rendering, and searching series is handled inside the shared module with zero code duplication.
Page Auto-Detection
Whenmain.js is loaded, it immediately evaluates two constants that determine the content type for the entire session:
window.location.pathname returns the path segment of the current URL (e.g. /series.html or /index.html). The .includes('series') check sets esPaginaSeries to true when the visitor is on series.html and false on index.html.
The tipo constant resolves to either 'tv' or 'movie' and is used in two places throughout main.js:
- Endpoint construction —
tipois interpolated directly into the TMDB URL path to target the correct API resource. - Field name resolution —
esPaginaSeriesis used in ternary expressions to readitem.name/item.first_air_datefor series, oritem.title/item.release_datefor movies.
Fetching Popular Series
Whenseries.html loads, obtenerContenido() is called with no arguments. With tipo set to 'tv', the function builds the following endpoint:
results array contains up to 20 TV series objects. These are passed directly to mostrarCards() for rendering.
TV Series vs Movie Fields
The TMDB API uses different field names for movies and TV series.main.js handles this with two ternary expressions evaluated inside mostrarCards():
- Movies
- TV Series
Fields read from each object in a
/movie/popular or /search/movie response:| Field | Type | Description |
|---|---|---|
item.title | string | The movie’s title |
item.release_date | string | ISO date string, e.g. "2024-07-19" — year extracted via .split('-')[0] |
item.poster_path | string | null | Relative poster image path |
titulo and año variables are what ultimately get rendered in the card — meaning the card template itself never needs to know which content type it is displaying.
Shared Card Rendering
BecausemostrarCards() only ever works with the pre-resolved titulo and año local variables, the HTML template it injects is completely identical for both movies and series:
if (esPaginaSeries) check inside mostrarCards(). The type-specific branching is fully resolved before the function is called, keeping the rendering logic clean and reusable. This also means any future change to the card layout (styling, added fields, click handlers) only needs to be made in one place.