feat: build official Goldebek municipal website
Deploy / validate-dispatch (push) Successful in 1s
Deploy / scheduled-rebuild-dev (push) Skipped
Deploy / scheduled-rebuild-master (push) Skipped
Deploy / rollback-dev (push) Skipped
Deploy / rollback-master (push) Skipped
Deploy / changes (push) Successful in 6s
Deploy / app-quality (push) Successful in 1m16s
Deploy / secret-scan (push) Successful in 4s
Deploy / security-deps (push) Successful in 18s
Deploy / context (push) Successful in 1s
Deploy / app-image (push) Successful in 1m28s
Deploy / deploy-master (push) Skipped
Deploy / deploy-dev (push) Successful in 13s
Deploy / validate-dispatch (push) Successful in 1s
Deploy / scheduled-rebuild-dev (push) Skipped
Deploy / scheduled-rebuild-master (push) Skipped
Deploy / rollback-dev (push) Skipped
Deploy / rollback-master (push) Skipped
Deploy / changes (push) Successful in 6s
Deploy / app-quality (push) Successful in 1m16s
Deploy / secret-scan (push) Successful in 4s
Deploy / security-deps (push) Successful in 18s
Deploy / context (push) Successful in 1s
Deploy / app-image (push) Successful in 1m28s
Deploy / deploy-master (push) Skipped
Deploy / deploy-dev (push) Successful in 13s
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { z } from "zod";
|
||||
|
||||
const root=path.resolve(import.meta.dirname,"..");
|
||||
const read=(file)=>JSON.parse(fs.readFileSync(path.join(root,file),"utf8"));
|
||||
const iso=z.string().regex(/^\d{4}-\d{2}-\d{2}$/).refine((value)=>new Date(`${value}T00:00:00Z`).toISOString().startsWith(value),"invalid date");
|
||||
const eventSchema=z.object({id:z.string().min(1),slug:z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),title:z.string().min(1),startDate:iso,startTime:z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/).optional(),endDate:iso.optional(),endTime:z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/).optional(),timezone:z.literal("Europe/Berlin"),location:z.string().optional(),sourceUrl:z.string().url().optional(),sourceName:z.string().optional(),lastVerified:iso,status:z.enum(["verified","dynamic","needs-verification","archived"]),privacyApproved:z.boolean().optional()});
|
||||
const sourceSchema=z.object({id:z.string().min(1),name:z.string().min(1),url:z.string().url(),type:z.string().min(1),lastVerified:iso});
|
||||
const newsSchema=z.object({id:z.string().min(1),slug:z.string(),title:z.string(),teaser:z.string(),body:z.string(),publishedAt:iso,updatedAt:iso.optional(),lastVerified:iso,status:z.enum(["published","draft","archived"]),sourceUrl:z.string().url().optional(),sourceName:z.string().optional()});
|
||||
const pagesSchema=z.array(z.object({slug:z.string().regex(/^[a-z0-9-]+(?:\/[a-z0-9-]+)*$/),title:z.string(),intro:z.string(),sections:z.array(z.object({title:z.string(),text:z.array(z.string()).optional(),items:z.array(z.string()).optional(),links:z.array(z.object({label:z.string(),href:z.string(),external:z.boolean().optional()})).optional()})),sourceId:z.string().optional(),lastVerified:iso.optional(),special:z.string().optional()}));
|
||||
const events=eventSchema.array().parse(read("content/events/events.json"));
|
||||
const news=newsSchema.array().parse([read("content/news/spielplatz-am-langbarg.json")]);
|
||||
const sources=sourceSchema.array().parse(read("data/sources.json"));
|
||||
const pages=pagesSchema.parse(read("content/pages/pages.json"));
|
||||
const services=read("data/services.json");
|
||||
const council=read("data/council.json");
|
||||
const projects=read("data/projects.json");
|
||||
const demographics=read("data/demographics.json");
|
||||
const administration=read("data/administration.json");
|
||||
const community=read("data/community.json");
|
||||
const sourceIds=new Set(sources.map((item)=>item.id));
|
||||
const unique=(items,key,label)=>{const seen=new Set();for(const item of items){const value=item[key];if(seen.has(value))throw new Error(`Doppelter ${label}: ${value}`);seen.add(value);}};
|
||||
unique(events,"slug","Termin-Slug");unique(news,"slug","News-Slug");unique(pages,"slug","Seiten-Slug");unique(sources,"id","Quellen-ID");
|
||||
for(const event of events){if((event.endDate??event.startDate)<event.startDate)throw new Error(`Enddatum vor Startdatum: ${event.slug}`);if(["verified","dynamic"].includes(event.status)&&(!event.sourceUrl||!event.sourceName))throw new Error(`Veröffentlichter Termin ohne Quelle: ${event.slug}`);if(event.location&&/\b\d+[a-z]?\b/i.test(event.location)&&event.privacyApproved!==true)throw new Error(`Adresse ohne privacyApproved: ${event.slug}`);new Intl.DateTimeFormat("de-DE",{weekday:"long",timeZone:"Europe/Berlin"}).format(new Date(`${event.startDate}T12:00:00Z`));}
|
||||
for(const page of pages){if(page.sourceId&&!sourceIds.has(page.sourceId))throw new Error(`Unbekannte Quelle auf ${page.slug}: ${page.sourceId}`);if((page.slug.startsWith("politik/")||page.slug.startsWith("service/"))&&(!page.sourceId||!page.lastVerified))throw new Error(`Verwaltungsinhalt ohne Quelle/Prüfstand: ${page.slug}`);}
|
||||
for(const record of [services.doerpshuus,services.everydayHelp,services.mobility,services.mobileLibrary,council]){if(!record.sourceId||!record.lastVerified)throw new Error("Dynamischer Datensatz ohne sourceId/lastVerified");if(!sourceIds.has(record.sourceId))throw new Error(`Unbekannte Quelle: ${record.sourceId}`);if(record.validUntil&&record.validUntil<new Date().toISOString().slice(0,10))throw new Error(`Abgelaufener Datensatz: ${record.sourceId}`);}
|
||||
for(const record of [demographics,administration,...projects]){if(record.status!=="needs-verification"&&(!record.sourceId||!record.lastVerified))throw new Error(`Dynamischer Datensatz ohne Quelle/Prüfstand: ${record.id??record.title??"unbekannt"}`);if(record.sourceId&&!sourceIds.has(record.sourceId))throw new Error(`Unbekannte Quelle: ${record.sourceId}`);}
|
||||
if(community.cultureCommittee.status==="needs-verification"&&community.cultureCommittee.privacyApproved!==false)throw new Error("Ungeprüfter privater Kontakt darf nicht freigegeben sein.");
|
||||
const routeSet=new Set(["/","/aktuelles","/termine","/impressum","/datenschutz","/barrierefreiheit",...pages.map((page)=>`/${page.slug}`),...events.map((event)=>`/termine/${event.slug}`),...news.map((item)=>`/aktuelles/${item.slug}`)]);
|
||||
for(const page of pages){for(const section of page.sections){for(const link of section.links??[]){if(link.href.startsWith("/")&&!routeSet.has(link.href.split("#")[0]))throw new Error(`Interner Link ohne Ziel auf ${page.slug}: ${link.href}`);}}}
|
||||
console.log(`Content validiert: ${pages.length} Seiten, ${news.length} Meldung, ${events.length} Termine, ${sources.length} Quellen.`);
|
||||
Reference in New Issue
Block a user