"""
return layout.layout("Page not found", body, path="/404.html", site=site)
def render_site(records, out_dir, repo_root, site=None):
"""Write every HTML page for the given records. Returns the number of pages written."""
site = site or site_settings.load()
copy_assets(out_dir)
pages = 0
for rec in records:
# Read by common.name() wherever a page shows the record's name as text.
rec["derived"]["name_lang"] = site.name_lang.get(rec["id"], "")
for rec in records:
copy_record_files(rec, out_dir, repo_root)
thumbs.prepare(rec, out_dir, repo_root)
title, description, body, needs_map = trail.render(rec, site)
path = f"/trails/{rec['id']}/"
layout.write_page(out_dir, path, layout.layout(title, body, path=path, description=description,
maps=needs_map, site=site))
pages += 1
dataset = seo.dataset_jsonld(records, site)
body = home.render(records, site)
layout.write_page(out_dir, "/", layout.layout("", body, path="/", maps=True, site=site, jsonld=dataset))
layout.write_page(out_dir, "/404.html", not_found_page(site))
pages += 2
def add(path, title, description, body_html, *, maps=False, jsonld=None):
nonlocal pages
layout.write_page(out_dir, path, layout.layout(
title, body_html, path=path, description=description, maps=maps, site=site, jsonld=jsonld))
pages += 1
t, d, b = regions.regions_index_page(records, site)
add("/regions/", t, d, b)
by_slug, _ = regions.collect_regions(records)
region_paths = []
for slug in sorted(by_slug):
t, d, b, needs_map = regions.region_page(slug, records, site)
path = f"/regions/{slug}/"
region_paths.append(path)
add(path, t, d, b, maps=needs_map)
t, d, b = regions.routes_page(records, site, repo_root)
add("/routes/", t, d, b)
t, d, b = docs.sources_page(records, site, repo_root)
add("/sources/", t, d, b)
t, d, b = docs.logos_page(records, site, repo_root)
add("/logos/", t, d, b)
t, d, b = docs.about_page(records, site, repo_root)
add("/about/", t, d, b)
t, d, b = docs.data_page(records, site, repo_root, out_dir)
add("/data/", t, d, b, jsonld=dataset)
t, d, b = docs.schema_page(site, repo_root)
add("/data/schema/", t, d, b)
t, d, b = docs.changelog_page(site, repo_root)
add("/data/changelog/", t, d, b)
docs.copy_licences(out_dir, repo_root)
seo.write_seo_files(out_dir, seo.all_paths(records, region_paths), site)
print(f"pages written {pages}: {len(records)} trail pages, home, 404, regions, routes, docs")
return pages