--- import type { CollectionEntry } from 'astro:content'; import { formatDate, processMarkdown, isValidDate } from '../utils/markdown'; import { siteConfig } from '../config'; import { getOptimizedFormat } from '@/utils/images'; import ImageWrapper from './ImageWrapper.astro'; import Icon from './Icon.astro'; interface Props { documentation: CollectionEntry<'docs'>; featured?: boolean; eager?: boolean; context?: 'featured' | 'recent' | 'docs' | 'tags' | 'home'; } const { documentation, featured = false, eager = false, context = 'docs' } = Astro.props; // Get excerpt from markdown processing const { excerpt } = processMarkdown(documentation.body); const { title, description: rawDescription, lastModified, image: rawImage, imageAlt, category, version } = documentation.data; // Process Obsidian bracket syntax in image field (copy from PostCard) const image = (() => { if (!rawImage) return rawImage; // Handle case where rawImage is an array (unquoted YAML syntax) let imageValue = rawImage; if (Array.isArray(rawImage)) { // If it's an array, take the first element imageValue = rawImage[0]; } // Ensure imageValue is a string before calling string methods if (typeof imageValue !== 'string') { console.warn('DocumentationCard: imageValue is not a string:', imageValue); return imageValue; } // Check if it's Obsidian double bracket syntax if (imageValue.startsWith('[[') && imageValue.endsWith(']]')) { // Extract the content inside the double brackets return imageValue.slice(2, -2); } return imageValue; })(); const description = rawDescription || excerpt; // Determine if we should show the cover image // Documentation should always show images when available (not controlled by postOptions) const shouldShowCoverImage = true; // Hide images for docs on homepage for cleaner look const showCoverImage = shouldShowCoverImage && image && context !== 'home'; ---