File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,8 +19,21 @@ export const useBlogImages = () => {
1919 * Get the generated OG image URL for a blog post path
2020 */
2121 const getOgImageUrl = ( path : string ) : string => {
22- // Convert path like '/blog/2.og-image-test' to 'blog/og-image-test'
23- return `http://localhost:3000/__og-image__/static${ path } /og.png`
22+ const config = useRuntimeConfig ( )
23+ const siteConfig = useSiteConfig ( )
24+
25+ // Get the base URL from site config or construct it
26+ const baseUrl = siteConfig . url || 'http://localhost:3000'
27+
28+ // Get the app base URL (e.g., '/litestar.dev-v2/')
29+ const appBase = config . app . baseURL || '/'
30+
31+ // Construct the full URL
32+ // Remove trailing slash from baseUrl and leading slash from appBase if needed
33+ const cleanBaseUrl = baseUrl . replace ( / \/ $ / , '' )
34+ const cleanAppBase = appBase === '/' ? '' : appBase . replace ( / \/ $ / , '' )
35+
36+ return `${ cleanBaseUrl } ${ cleanAppBase } /__og-image__/static${ path } /og.png`
2437 }
2538
2639 /**
Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ export default defineNuxtConfig({
4848 'motion-v/nuxt' ,
4949 '@nuxtjs/google-fonts' ,
5050 ] ,
51+ site : {
52+ url : process . env . NUXT_PUBLIC_SITE_URL || 'https://litestar-org.github.io' ,
53+ } ,
5154 $development : {
5255 site : {
5356 url : 'http://localhost:3000' ,
You can’t perform that action at this time.
0 commit comments