mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 11:41:17 +02:00
test: og url end with slash
This commit is contained in:
parent
79f9765688
commit
c97e3d5882
9 changed files with 82 additions and 15 deletions
|
@ -1,14 +1,14 @@
|
|||
---
|
||||
import themeConfig from '@/config'
|
||||
import { isPostPage } from '@/utils/path'
|
||||
import { ClientRouter } from 'astro:transitions'
|
||||
|
||||
interface Props {
|
||||
postTitle?: string
|
||||
postDescription?: string
|
||||
postImage?: string
|
||||
}
|
||||
|
||||
const { postTitle, postDescription, postImage } = Astro.props
|
||||
const { postTitle, postDescription } = Astro.props
|
||||
|
||||
const { title, subtitle, description, author, url, favicon } = themeConfig.site
|
||||
const { mode, light: { background: lightMode }, dark: { background: darkMode } } = themeConfig.color
|
||||
|
@ -20,7 +20,18 @@ const { commentURL = '', imageHostURL = '', customGoogleAnalyticsJS = '', custom
|
|||
const initMetaTheme = mode === 'dark' ? darkMode : lightMode
|
||||
const pageTitle = postTitle ? `${postTitle} | ${title}` : `${title} - ${subtitle}`
|
||||
const pageDescription = postDescription || description
|
||||
const pageImage = postImage || favicon
|
||||
|
||||
// Determine the OG image for the page
|
||||
// Check if the current page is a post
|
||||
const currentPath = Astro.url.pathname
|
||||
const isPost = isPostPage(currentPath)
|
||||
|
||||
// Extract slug from URL as the post identifier
|
||||
const pathParts = currentPath.split('/').filter(part => part !== '')
|
||||
const slug = pathParts.length > 0 ? pathParts[pathParts.length - 1] : ''
|
||||
|
||||
// Prioritize auto-generated OG image, otherwise use fallback OG image
|
||||
const pageImage = isPost && slug ? `${url}/og/${slug}` : favicon
|
||||
---
|
||||
|
||||
<head>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue