.PHONY: dev build build-clean build-local items brand-content preview clean help

# Paths and settings
HUGO_BIN := ./hugo-bin/hugo
HUGO_SRC := hugo
DEST := public
DEV_PORT := 1313
PREVIEW_PORT := 8000
PIPELINE := ../../cloudflare-pipeline

help:
	@echo "Available targets:"
	@echo "  make dev           # Start Hugo dev server with live reload"
	@echo "  make items         # Generate SKU pages and sitemaps via Python"
	@echo "  make brand-content # Generate static brand content pages for SEO"
	@echo "  make build         # Build Hugo site to ./public (keep existing)"
	@echo "  make build-clean   # Clean ./public then build"
	@echo "  make build-local   # Build with baseURL=http://localhost:8000/"
	@echo "  make preview       # Serve ./public on :8000"
	@echo "  make clean         # Remove ./public directory"

dev:
	$(HUGO_BIN) server --source $(HUGO_SRC) --port $(DEV_PORT) --disableFastRender --navigateToChanged

items:
	python3 $(PIPELINE)/legacy-builder/builder/build_items.py

brand-content:
	python3 $(PIPELINE)/digikey_search/generate_brand_content.py

build:
	python3 $(PIPELINE)/legacy-builder/builder/build_items.py
	$(HUGO_BIN) --source $(HUGO_SRC) --destination $(DEST) --minify --cleanDestinationDir

build-clean:
	rm -rf $(DEST)
	python3 $(PIPELINE)/legacy-builder/builder/build_items.py
	$(HUGO_BIN) --source $(HUGO_SRC) --destination $(DEST) --minify --cleanDestinationDir

build-local:
	$(HUGO_BIN) --source $(HUGO_SRC) --destination $(DEST) --minify --baseURL http://localhost:$(PREVIEW_PORT)/

preview:
	python3 -m http.server $(PREVIEW_PORT) --directory $(DEST)

clean:
	rm -rf $(DEST)
