--- import Layout from '../../layouts/Layout.astro'; import { getCollection, getEntry } from 'astro:content'; import Comments from "../../components/Comments.astro"; import {getImage} from "astro:assets"; import {siteConfig} from "../../config"; import ReplyViaEmail from "../../components/ReplyViaEmail.astro"; import { ExtractFirstImage } from '../../plugins/extract-images'; import AuthorInfo from "../../components/helper/authors/Info.astro"; import TableOfContents from "../../components/TableOfContents.astro"; import "katex/dist/katex.css" export async function getStaticPaths() { const blogEntries = await getCollection('posts'); return blogEntries.map(entry => ({ params: { slug: entry.slug }, props: { entry }, })); } const { entry } = Astro.props; const { Content } = await entry.render(); const headings = await entry.render().then(rendered => rendered.headings); const noscript = siteConfig.noClientJavaScript const slug = Astro.params.slug; const author = entry.data.author || {collection: 'authors', id: siteConfig.defaultAuthor.id}; // Get author data const authorData = await getEntry(author); const authorInfo = authorData ? authorData.data : siteConfig.defaultAuthor; // get featured image and use it as og:image // use the custom cover image if it exists, otherwise use the featured image file in the same directory const featuredImages = import.meta.glob(`/src/content/posts/*/featured.{avif,png,jpg,jpeg,webp}`,{import:'default',eager:true}); const customFeaturedImage = entry.data.cover?.src const matchedImage = Object.keys(featuredImages).find(path => path.includes(slug)); let matchedImage_src; if (matchedImage && !customFeaturedImage) { matchedImage_src = await getImage({src: featuredImages[matchedImage], format: 'webp'}) || null; } const firstImageURL = await ExtractFirstImage(Content) const cover = customFeaturedImage || matchedImage_src?.src || firstImageURL || `/blog/${slug}/featured.png` || ''; ---

{entry.data.title}

{new Date(entry.data.pubDate).toISOString().split('T')[0]} {headings.length !== 0 && }

← Back to posts {!noscript &&

Comments

} {!noscript && }