Remove deprecated scripts for adding head-matter to wt_config.xml, including Python and Bash implementations, to streamline configuration management.
This commit is contained in:
126
server/routes-seo.js
Normal file
126
server/routes-seo.js
Normal file
@@ -0,0 +1,126 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
// SEO-Meta-Daten für verschiedene Routen
|
||||
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: 'https://ypchat.net/',
|
||||
ogImage: 'https://ypchat.net/static/favicon.png'
|
||||
},
|
||||
'/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: 'https://ypchat.net/partners',
|
||||
ogImage: 'https://ypchat.net/static/favicon.png'
|
||||
}
|
||||
};
|
||||
|
||||
// HTML-Template für Pre-Rendering
|
||||
function generateHTML(route, meta) {
|
||||
const baseHTML = `<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<!-- SEO Meta Tags -->
|
||||
<title>${meta.title}</title>
|
||||
<meta name="description" content="${meta.description}">
|
||||
<meta name="keywords" content="${meta.keywords}">
|
||||
<meta name="robots" content="index, follow">
|
||||
|
||||
<!-- Open Graph Tags -->
|
||||
<meta property="og:title" content="${meta.ogTitle}">
|
||||
<meta property="og:description" content="${meta.ogDescription}">
|
||||
<meta property="og:type" content="${meta.ogType}">
|
||||
<meta property="og:url" content="${meta.ogUrl}">
|
||||
<meta property="og:image" content="${meta.ogImage}">
|
||||
|
||||
<!-- Twitter Card -->
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:title" content="${meta.ogTitle}">
|
||||
<meta name="twitter:description" content="${meta.ogDescription}">
|
||||
<meta name="twitter:image" content="${meta.ogImage}">
|
||||
|
||||
<!-- Canonical URL -->
|
||||
<link rel="canonical" href="${meta.ogUrl}">
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="icon" type="image/png" href="/static/favicon.png">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
</body>
|
||||
</html>`;
|
||||
|
||||
return baseHTML;
|
||||
}
|
||||
|
||||
export function setupSEORoutes(app, __dirname) {
|
||||
// Pre-Rendering für SEO-relevante Routen (nur in Production)
|
||||
// In Development wird die normale index.html verwendet
|
||||
const IS_PRODUCTION = process.env.NODE_ENV === 'production';
|
||||
|
||||
if (IS_PRODUCTION) {
|
||||
// Pre-Rendering für Hauptseite
|
||||
app.get('/', (req, res) => {
|
||||
const meta = seoData['/'];
|
||||
const html = generateHTML('/', meta);
|
||||
res.send(html);
|
||||
});
|
||||
|
||||
// Pre-Rendering für Partners-Seite
|
||||
app.get('/partners', (req, res) => {
|
||||
const meta = seoData['/partners'];
|
||||
const html = generateHTML('/partners', meta);
|
||||
res.send(html);
|
||||
});
|
||||
}
|
||||
|
||||
// robots.txt
|
||||
app.get('/robots.txt', (req, res) => {
|
||||
const robotsTxt = `User-agent: *
|
||||
Allow: /
|
||||
Allow: /partners
|
||||
Disallow: /api/
|
||||
Disallow: /static/logs/
|
||||
|
||||
Sitemap: https://ypchat.net/sitemap.xml
|
||||
`;
|
||||
res.type('text/plain');
|
||||
res.send(robotsTxt);
|
||||
});
|
||||
|
||||
// sitemap.xml
|
||||
app.get('/sitemap.xml', (req, res) => {
|
||||
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<url>
|
||||
<loc>https://ypchat.net/</loc>
|
||||
<lastmod>${new Date().toISOString().split('T')[0]}</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
<priority>1.0</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://ypchat.net/partners</loc>
|
||||
<lastmod>${new Date().toISOString().split('T')[0]}</lastmod>
|
||||
<changefreq>weekly</changefreq>
|
||||
<priority>0.8</priority>
|
||||
</url>
|
||||
</urlset>`;
|
||||
res.type('application/xml');
|
||||
res.send(sitemap);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user