import { readFileSync, existsSync } from 'fs'; import { join, resolve } from 'path'; import { loadFeedback } from './feedback-store.js'; const SITE_URL = 'https://www.ypchat.net'; const DEFAULT_IMAGE = `${SITE_URL}/static/favicon.png`; const seoData = { '/': { title: 'SingleChat - Chat, Single-Chat und Bildaustausch', description: 'Willkommen auf SingleChat - deine erste Adresse für Chat, Single-Chat und Bildaustausch. Chatte mit Menschen aus aller Welt, finde neue Kontakte und teile Erinnerungen sicher und komfortabel.', keywords: 'Chat, Single-Chat, Bildaustausch, Online-Chat, Singles, Kontakte, Community', ogTitle: 'SingleChat - Chat, Single-Chat und Bildaustausch', ogDescription: 'Willkommen auf SingleChat - deine erste Adresse für Chat, Single-Chat und Bildaustausch.', ogType: 'website', ogUrl: `${SITE_URL}/`, ogImage: DEFAULT_IMAGE, robots: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1', schema: { '@context': 'https://schema.org', '@type': 'WebSite', name: 'SingleChat', url: `${SITE_URL}/`, description: 'Willkommen auf SingleChat - deine erste Adresse für Chat, Single-Chat und Bildaustausch.', inLanguage: 'de-DE' } }, '/partners': { title: 'Partner - SingleChat', description: 'Unsere Partner und befreundete Seiten. Entdecke weitere interessante Angebote und Communities.', keywords: 'Partner, Links, befreundete Seiten, Community', ogTitle: 'Partner - SingleChat', ogDescription: 'Unsere Partner und befreundete Seiten.', ogType: 'website', ogUrl: `${SITE_URL}/partners`, ogImage: DEFAULT_IMAGE, robots: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1', schema: { '@context': 'https://schema.org', '@type': 'CollectionPage', name: 'Partner - SingleChat', url: `${SITE_URL}/partners`, description: 'Unsere Partner und befreundete Seiten. Entdecke weitere interessante Angebote und Communities.', isPartOf: { '@type': 'WebSite', name: 'SingleChat', url: `${SITE_URL}/` }, inLanguage: 'de-DE' } }, '/feedback': { title: 'Feedback - SingleChat', description: 'Oeffentliche Rueckmeldungen, Meinungen und Verbesserungsvorschlaege zu SingleChat.', keywords: 'SingleChat Feedback, Kommentare, Rueckmeldungen, Verbesserungsvorschlaege', ogTitle: 'Feedback - SingleChat', ogDescription: 'Oeffentliche Rueckmeldungen, Meinungen und Verbesserungsvorschlaege zu SingleChat.', ogType: 'website', ogUrl: `${SITE_URL}/feedback`, ogImage: DEFAULT_IMAGE, robots: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1', schema: { '@context': 'https://schema.org', '@type': 'CollectionPage', name: 'Feedback - SingleChat', url: `${SITE_URL}/feedback`, description: 'Oeffentliche Rueckmeldungen, Meinungen und Verbesserungsvorschlaege zu SingleChat.', isPartOf: { '@type': 'WebSite', name: 'SingleChat', url: `${SITE_URL}/` }, inLanguage: 'de-DE' } }, '/faq': { title: 'FAQ - SingleChat', description: 'Häufige Fragen zu SingleChat: Einstieg, Privatsphäre, Bildaustausch, Blockieren und mehr.', keywords: 'SingleChat FAQ, Hilfe, Privatsphäre, Blockieren, Bilder, Chat', ogTitle: 'FAQ - SingleChat', ogDescription: 'Antworten auf häufige Fragen rund um SingleChat.', ogType: 'website', ogUrl: `${SITE_URL}/faq`, ogImage: DEFAULT_IMAGE, robots: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1', schema: { '@context': 'https://schema.org', '@type': 'FAQPage', name: 'FAQ - SingleChat', url: `${SITE_URL}/faq`, description: 'Häufige Fragen zu SingleChat: Einstieg, Privatsphäre, Bildaustausch, Blockieren und mehr.', isPartOf: { '@type': 'WebSite', name: 'SingleChat', url: `${SITE_URL}/` }, inLanguage: 'de-DE' } }, '/regeln': { title: 'Regeln - SingleChat', description: 'Chat-Regeln für ein respektvolles und sicheres Miteinander auf SingleChat.', keywords: 'SingleChat Regeln, Chat Regeln, Community, Sicherheit', ogTitle: 'Regeln - SingleChat', ogDescription: 'Chat-Regeln für ein respektvolles und sicheres Miteinander.', ogType: 'website', ogUrl: `${SITE_URL}/regeln`, ogImage: DEFAULT_IMAGE, robots: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1', schema: { '@context': 'https://schema.org', '@type': 'WebPage', name: 'Regeln - SingleChat', url: `${SITE_URL}/regeln`, description: 'Chat-Regeln für ein respektvolles und sicheres Miteinander auf SingleChat.', isPartOf: { '@type': 'WebSite', name: 'SingleChat', url: `${SITE_URL}/` }, inLanguage: 'de-DE' } }, '/sicherheit': { title: 'Sicherheit & Privatsphäre - SingleChat', description: 'Hinweise zu Privatsphäre, Blockieren/Melden und sicherer Nutzung von SingleChat.', keywords: 'SingleChat Sicherheit, Privatsphäre, Blockieren, Melden', ogTitle: 'Sicherheit & Privatsphäre - SingleChat', ogDescription: 'Hinweise zu Privatsphäre, Blockieren/Melden und sicherer Nutzung.', ogType: 'website', ogUrl: `${SITE_URL}/sicherheit`, ogImage: DEFAULT_IMAGE, robots: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1', schema: { '@context': 'https://schema.org', '@type': 'WebPage', name: 'Sicherheit & Privatsphäre - SingleChat', url: `${SITE_URL}/sicherheit`, description: 'Hinweise zu Privatsphäre, Blockieren/Melden und sicherer Nutzung von SingleChat.', isPartOf: { '@type': 'WebSite', name: 'SingleChat', url: `${SITE_URL}/` }, inLanguage: 'de-DE' } } }; function buildSitemapXml() { const currentDate = new Date().toISOString().split('T')[0]; const urls = Object.entries(seoData) .map(([route, meta]) => { const priority = route === '/' ? '1.0' : '0.8'; const changefreq = route === '/' ? 'daily' : 'weekly'; return ` ${meta.ogUrl} ${currentDate} ${changefreq} ${priority} `; }) .join('\n'); return ` ${urls} `; } function escapeHtml(value = '') { return String(value) .replace(/&/g, '&') .replace(/"/g, '"') .replace(//g, '>'); } function upsertMetaTag(html, name, content, attribute = 'name') { const escapedContent = escapeHtml(content); const regex = new RegExp(`]*>`, 'g'); const tag = ``; if (regex.test(html)) { return html.replace(regex, tag); } return html.replace('', ` ${tag}\n`); } function upsertLinkTag(html, rel, href) { const escapedHref = escapeHtml(href); const regex = new RegExp(`]*>`, 'g'); const tag = ``; if (regex.test(html)) { return html.replace(regex, tag); } return html.replace('', ` ${tag}\n`); } function upsertJsonLd(html, schema) { const tag = schema ? `` : ''; if (html.includes('id="seo-json-ld"')) { return html.replace(/