feat: Add post-content styles and improve breadcrumb and link styles

This commit is contained in:
kbe
2025-08-19 12:05:46 +02:00
parent 78c41cc071
commit e662c7cda4
12 changed files with 103 additions and 10885 deletions

View File

@@ -54,14 +54,20 @@ function generateContent() {
// Decode HTML entities in the content and clean up HTML tags
let contentHtml = he.decode(post.content.rendered);
// Convert absolute URLs in a href to relative URLs
// Convert absolute URLs in a href to relative URLs (only for wp.mistergeek.net)
contentHtml = contentHtml.replace(/<a\s+[^>]*href="([^"]+)"[^>]*>/g, (match, href) => {
// Check if the href is an absolute URL (starts with http:// or https://)
// Check if the href is an absolute URL containing wp.mistergeek.net
if (href.startsWith('http://') || href.startsWith('https://')) {
// Extract the path part of the URL
const url = new URL(href);
// Return the modified a tag with relative URL
return match.replace(href, url.pathname);
try {
const url = new URL(href);
if (url.hostname === 'wp.mistergeek.net' || url.hostname === 'www.wp.mistergeek.net') {
// Only convert wp.mistergeek.net URLs to relative paths
return match.replace(href, url.pathname);
}
} catch (error) {
// If URL parsing fails, return the original href
console.warn('Failed to parse URL:', href, error);
}
}
return match;
});
@@ -105,14 +111,20 @@ ${contentHtml.trim()}`;
// Decode HTML entities in the content and clean up HTML tags
let contentHtml = he.decode(page.content.rendered);
// Convert absolute URLs in a href to relative URLs
// Convert absolute URLs in a href to relative URLs (only for wp.mistergeek.net)
contentHtml = contentHtml.replace(/<a\s+[^>]*href="([^"]+)"[^>]*>/g, (match, href) => {
// Check if the href is an absolute URL (starts with http:// or https://)
// Check if the href is an absolute URL containing wp.mistergeek.net
if (href.startsWith('http://') || href.startsWith('https://')) {
// Extract the path part of the URL
const url = new URL(href);
// Return the modified a tag with relative URL
return match.replace(href, url.pathname);
try {
const url = new URL(href);
if (url.hostname === 'wp.mistergeek.net' || url.hostname === 'www.wp.mistergeek.net') {
// Only convert wp.mistergeek.net URLs to relative paths
return match.replace(href, url.pathname);
}
} catch (error) {
// If URL parsing fails, return the original href
console.warn('Failed to parse URL:', href, error);
}
}
return match;
});