Static frontend that searches The Movie Database (TMDB) and shows details: summary, cast, genres, runtime, poster and trailers.
Setup
- Get a TMDB API key: https://www.themoviedb.org/settings/api
- Copy
config.example.jstoconfig.jsnext to the HTML files and set your key.
Files
index.html— main pagestyles.css— UI styles (light theme, red accent)script.js— frontend logic that calls TMDBconfig.example.js— template for your API key
Run
Open index.html in your browser (no build step required). If you want a local static server (recommended), you can use any static server. Example using Node's http-server (install globally):
npx http-server -c-1 .Notes
- Don't commit
config.jswith your real API key. - The app uses TMDB's search and movie details endpoints and embeds YouTube trailers when available.
Ads
- This project includes placeholder ad slots in
index.html(top banner, sidebar, footer) and inserts inline ad cards into the results every 6 items. - To integrate a real ad network (AdSense/GAM or other), load the network's script in the page and then register a callback using
window.registerAdHook(fn). - The hook
fnwill be called after ad slots are inserted; inside it you can render or refresh ads into elements with classad-slotorinline-ad.
Important: do not place real ad network scripts or keys into source control while developing. Use environment-specific injection or server-side rendering for production.
AdSense setup (quick start)
- Sign up for Google AdSense and add your site URL in the AdSense dashboard. Use the URL where you'll host this project (for local testing you can register a temporary domain or use a public test site).
- After AdSense approves your site, you'll receive a script snippet from Google. Do NOT paste it into version-controlled files. Instead, create
ads.json your production host that contains the AdSense loader. - Use the provided
ads.example.jsas a safe template.ads.example.jsdemonstrates how to registerwindow.registerAdHook()so the ad loader can render into.ad-slotand.inline-adelements.
Consent and privacy
- If you expect traffic from GDPR regions, you must show a consent banner and block personalized ads until the user accepts. This project includes a simple CMP banner and will only load
ads.jsafter the user clicks Accept. - For production, consider integrating a full CMP (IAB TCF-compliant) or a paid provider for enterprise needs.
Prevent committing secrets
- A
.gitignorehas been added that ignoresconfig.js,ads.js, and common env files. Make sure you keep your real API keys and ad scripts out of version control. - Optional pre-commit hook: a sample hook is available at
hooks/pre-commit. To enable it, run:
copy .\hooks\pre-commit .git\hooks\pre-commit
# On Unix/macOS:
# cp hooks/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commitThis hook blocks commits that include config.js, ads.js, or .env files. It's a convenience, not a replacement for careful secret handling.
One-time setup helper
Run the included setup.ps1 (Windows PowerShell) to install the pre-commit hook and create local config stubs:
.\setup.ps1This will:
- copy the
hooks/pre-commitinto.git/hooks/pre-commit - create a local
.envfrom.env.example(if missing) - move an existing
config.jstoconfig.js.bakand createconfig.template.js
Sanitizing before push
If you have local config.js or ads.js, run sanitize_repo.ps1 to back them up (to config.local.js/ads.local.js) and untrack them from git before pushing.
.\sanitize_repo.ps1Deployment (GitHub + Netlify / Vercel)
-
Quick deploy to Netlify (recommended for static + functions):
- Create a Netlify account and connect the GitHub repo https://github.com/syntaxdrive/AboutMovie.git.
- In Netlify site settings, set the publish directory to the repo root.
- Optionally add the Netlify Functions directory
netlify/functionsfor the newsletter function scaffold. - Add any environment variables (MAILCHIMP_API_KEY, etc.) in Site settings -> Build & deploy -> Environment.
-
Quick deploy to Vercel:
- Create a Vercel account and import the GitHub repo.
- Add environment variables in the Vercel dashboard.
Ads & newsletter notes
- Example ad loaders were added:
ads.example.jsandads.example-adsense.js. Copy one toads.json your production host and replace publisher IDs there. - An
ads.txttemplate was added at the project root — update with your authorized sellers before publishing. - A Netlify serverless function scaffold is provided at
netlify/functions/subscribe.js. Implement provider integration and set provider API keys as environment variables on Netlify/Vercel.
Search Console / Verification
- To verify your site in Google Search Console using the HTML file method, add a file named
google-site-verification-<token>.htmlto your site root with the token supplied by Google. A templategoogle-site-verification-example.htmlis included in this repo. - Alternatively, use DNS verification if you control your domain's DNS records.
Newsletter
- The footer newsletter form will POST to the endpoint defined by
window.NEWSLETTER_ENDPOINTif you set it inconfig.local.js(for example:window.NEWSLETTER_ENDPOINT = 'https://api.yourservice.com/subscribe'). - If no endpoint is configured, the form falls back to storing subscriptions in
localStorage(demo only). For production, implement a small serverless function (Netlify Functions, Vercel Serverless, AWS Lambda) or a provider endpoint (Mailchimp API, Buttondown) to accept and store emails securely.
Example config.local.js additions (DO NOT COMMIT):
// TMDB key
window.TMDB_API_KEY = "your_tmdb_key_here";
// optional: GA4 measurement id
window.GA_MEASUREMENT_ID = "G-XXXXXXXXXX";
// optional: newsletter endpoint used by the footer form
window.NEWSLETTER_ENDPOINT = "https://api.yourservice.com/subscribe";