Pelisgo includes a real-time search feature that is active on both the movies page (Documentation 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.
index.html) and the series page (series.html). As you type in the search bar, main.js fires a live query against the TMDB search API and immediately replaces the card grid with the matching results. The search is context-aware: it automatically targets /search/movie on the movies page and /search/tv on the series page, using the same tipo variable that controls the popular feed.
The Search Input
The search bar is rendered inside the navbar as a plain<input> element, positioned at the far right of the navigation list:
styles.css with a blueviolet background, white text and placeholder, rounded corners (border-radius: 15px), and a fixed width of 200px on desktop (expanding to 90% of the viewport on mobile).
main.js grabs a reference to this element on load:
Search Event Handler
The search is driven by akeyup event listener attached to the input element. The listener checks the current value length on every keystroke and applies two-condition logic to decide what to fetch:
| Condition | Trigger | Action |
|---|---|---|
e.target.value.length > 2 | User has typed 3 or more characters | Calls obtenerContenido(query) with the current input value as the search term |
e.target.value === "" | The input field has been completely cleared | Calls obtenerContenido() with no arguments, reverting the grid to the popular list |
if (buscador) guard at the top prevents a JavaScript error if the element is missing from the page (for example, on any future pages that reuse main.js without a search bar).
Search Endpoint
When a search query is provided,obtenerContenido() constructs the TMDB search endpoint instead of the popular endpoint:
{tipo}ismovieonindex.htmlortvonseries.html{searchTerm}is the raw value of the search input, URL-encoded automatically byfetch()
Search vs Popular Mode
TheobtenerContenido() function handles both modes through a single if (query) branch. When called with an argument it targets the search endpoint; when called with no argument (or an empty string, the default) it targets the popular endpoint:
results array in the same TMDB response shape, so mostrarCards() receives identical input regardless of whether the data came from a search query or the popular feed. The grid is fully replaced on every call (seccionContenido.innerHTML = '' runs first inside mostrarCards()), so switching between search results and the popular list is seamless.
Search results are rendered using the exact same
mostrarCards() function as the popular feed. This means search result cards are visually identical to the default cards — same poster image, title, and year layout — with no additional template or styling required.