diff --git a/public/images/blog-vllm.png b/public/images/blog-vllm.png new file mode 100644 index 0000000..e69de29 diff --git a/theme.config.tsx b/theme.config.tsx index 585622d..de9cc78 100644 --- a/theme.config.tsx +++ b/theme.config.tsx @@ -1,7 +1,7 @@ import { DiscordIcon } from 'nextra/icons' import { Bot, Heart, Code2 } from "lucide-react" import websiteConfig from '@/build/fixtures/website-config.json' -import { Link } from "nextra-theme-docs" +import { Link, useConfig } from "nextra-theme-docs" import { BlogPostHeader, BlogPostFooter } from '@/components/blog-post' import { useRouter } from 'next/router' @@ -68,25 +68,99 @@ const themeConfig = { titleTemplate: '%s - WATcloud', } }, - head: () => ( - <> - - - + head: function Head() { + const { frontMatter } = useConfig(); + const { route } = useRouter(); + + // Check if this is a blog post + const isBlogPost = route.startsWith('/blog/') && route !== '/blog'; + + // Default meta tags + const metaTags = [ + , + , + , + />, - - ), + ]; + + // Add Open Graph and Twitter Card meta tags for blog posts + if (isBlogPost && frontMatter) { + const { title, description, title_image } = frontMatter; + const siteUrl = 'https://cloud.watonomous.ca'; // TODO: Get from config + const currentUrl = `${siteUrl}${route}`; + + // Add basic Open Graph tags + metaTags.push( + , + , + + ); + + if (title) { + metaTags.push( + , + + ); + } + + if (description) { + metaTags.push( + , + + ); + } + + // Add image meta tags if title_image exists + if (title_image) { + // For now, we'll create a simple mapping from image keys to static paths + // In production, this would use the actual image fixtures + const imageKey = title_image.wide || title_image.square; + let imageUrl = ''; + + // Simple static mapping for known blog images + if (imageKey === 'blog-vllm-wide' || imageKey === 'blog-vllm-square') { + imageUrl = `${siteUrl}/images/blog-vllm.png`; + } + + if (imageUrl) { + metaTags.push( + , + , + , + , + + ); + + if (title_image.attribution) { + metaTags.push( + , + + ); + } + } + } else { + // Add basic Twitter card for blog posts without images + metaTags.push( + + ); + } + } + + return <>{metaTags}; + }, footer: { text: ( // Maybe create a footer component instead?