BReadcrumbs

This commit is contained in:
2025-11-26 17:13:42 +01:00
parent d38ba85f4f
commit 09c77f5414
15 changed files with 663 additions and 8 deletions

79
src/composables/useSEO.ts Normal file
View File

@@ -0,0 +1,79 @@
import { useHead } from '@vueuse/head';
export interface SEOMetaData {
title: string;
description: string;
image?: string;
url?: string;
type?: 'website' | 'article';
author?: string;
publishedTime?: string;
modifiedTime?: string;
keywords?: string;
}
const SITE_NAME = 'Spritesheet Generator';
const SITE_URL = 'https://spritesheetgenerator.online';
const DEFAULT_IMAGE = '/og-image.png';
export function useSEO(metadata: SEOMetaData) {
const fullTitle = metadata.title.includes(SITE_NAME)
? metadata.title
: `${metadata.title} - ${SITE_NAME}`;
const fullUrl = metadata.url
? `${SITE_URL}${metadata.url}`
: SITE_URL;
const imageUrl = metadata.image
? `${SITE_URL}${metadata.image}`
: `${SITE_URL}${DEFAULT_IMAGE}`;
const metaTags: any[] = [
// Primary Meta Tags
{ name: 'title', content: fullTitle },
{ name: 'description', content: metadata.description },
{ name: 'robots', content: 'index, follow' },
// Open Graph / Facebook
{ property: 'og:type', content: metadata.type || 'website' },
{ property: 'og:url', content: fullUrl },
{ property: 'og:title', content: fullTitle },
{ property: 'og:description', content: metadata.description },
{ property: 'og:image', content: imageUrl },
{ property: 'og:site_name', content: SITE_NAME },
// Twitter
{ name: 'twitter:card', content: 'summary_large_image' },
{ name: 'twitter:url', content: fullUrl },
{ name: 'twitter:title', content: fullTitle },
{ name: 'twitter:description', content: metadata.description },
{ name: 'twitter:image', content: imageUrl },
];
// Add article-specific meta tags
if (metadata.type === 'article') {
if (metadata.author) {
metaTags.push({ property: 'article:author', content: metadata.author });
}
if (metadata.publishedTime) {
metaTags.push({ property: 'article:published_time', content: metadata.publishedTime });
}
if (metadata.modifiedTime) {
metaTags.push({ property: 'article:modified_time', content: metadata.modifiedTime });
}
}
// Add keywords if provided
if (metadata.keywords) {
metaTags.push({ name: 'keywords', content: metadata.keywords });
}
useHead({
title: fullTitle,
meta: metaTags,
link: [
{ rel: 'canonical', href: fullUrl }
]
});
}