diff --git a/src/content/posts/terminal-setup/index.md b/src/content/posts/terminal-setup/index.md index b706e84..3ae2f95 100644 --- a/src/content/posts/terminal-setup/index.md +++ b/src/content/posts/terminal-setup/index.md @@ -3,7 +3,7 @@ title: 'My Terminal Setup' description: 'A walkthrough of my current terminal configuration' pubDate: '2025-06-08' --- - +![cover](./demo.png) Here's my current terminal setup: - Shell: ZSH with Oh My Zsh diff --git a/src/pages/post/[...slug].astro b/src/pages/post/[...slug].astro index 5637409..59049c3 100644 --- a/src/pages/post/[...slug].astro +++ b/src/pages/post/[...slug].astro @@ -3,12 +3,9 @@ import Layout from '../../layouts/Layout.astro'; import { getCollection, getEntry } from 'astro:content'; import Comments from "../../components/Comments.astro"; import {getImage} from "astro:assets"; -import { unified } from "unified"; -import { select } from "unist-util-select"; -import remarkMdx from "remark-mdx"; -import remarkParse from "remark-parse"; import {siteConfig} from "../../config"; import ReplyViaEmail from "../../components/ReplyViaEmail.astro"; +import { ExtractFirstImage } from '../../plugins/extract-images'; export async function getStaticPaths() { const blogEntries = await getCollection('posts'); @@ -36,8 +33,9 @@ let matchedImage_src; if (matchedImage && !customFeaturedImage) { matchedImage_src = await getImage({src: featuredImages[matchedImage], format: 'webp'}) || null; } +const firstImageURL = await ExtractFirstImage(Content,Astro.url.origin) -const cover = customFeaturedImage || matchedImage_src?.src || `/post/${slug}/featured.png` || ''; +const cover = customFeaturedImage || matchedImage_src?.src || firstImageURL || `/post/${slug}/featured.png` || ''; --- /, ''), [ + async (node) => { + await walk(node, (node) => { + if (node.name === "img" && node.attributes.src) { + // Store the first image URL we find + if (!firstImageUrl) { + firstImageUrl = node.attributes.src.startsWith("/") + ? baseUrl + node.attributes.src + : node.attributes.src; + } + // Still update the src attribute if needed + if (node.attributes.src.startsWith("/")) { + node.attributes.src = baseUrl + node.attributes.src; + } + } + }); + return node; + } + ]); + + // Return the URL value, not a Promise + return firstImageUrl; +} \ No newline at end of file