@@ -4,12 +4,13 @@ import mdx from '@astrojs/mdx';
44import sitemap from '@astrojs/sitemap' ;
55import { visit } from 'unist-util-visit' ;
66
7- // Always deploy to https://blog.trustyai.org with root path
8- const baseUrl = '' ;
7+ // Always use the full site URL for absolute links
8+ const siteUrl = 'https://blog.trustyai.org' ;
9+ const baseUrl = siteUrl ;
910
1011console . log ( 'Build environment:' , {
11- site : 'https://blog.trustyai.org' ,
12- baseUrl : baseUrl || '(root path)' ,
12+ site : siteUrl ,
13+ baseUrl : baseUrl ,
1314 NODE_ENV : process . env . NODE_ENV
1415} ) ;
1516
@@ -18,9 +19,9 @@ function remarkBaseUrl() {
1819 // @ts -ignore
1920 return ( tree ) => {
2021 visit ( tree , 'image' , ( node ) => {
21- if ( node . url && node . url . startsWith ( '/' ) && ! node . url . startsWith ( '/trustyai-blog/' ) ) {
22- console . log ( `Transforming image URL: ${ node . url } -> ${ baseUrl } ${ node . url } ` ) ;
23- node . url = `${ baseUrl } ${ node . url } ` ;
22+ if ( node . url && node . url . startsWith ( '/' ) && ! node . url . startsWith ( siteUrl ) ) {
23+ console . log ( `Transforming image URL: ${ node . url } -> ${ siteUrl } ${ node . url } ` ) ;
24+ node . url = `${ siteUrl } ${ node . url } ` ;
2425 }
2526 } ) ;
2627 // Also handle HTML img tags in MDX
@@ -29,8 +30,8 @@ function remarkBaseUrl() {
2930 node . value = node . value . replace (
3031 / s r c = " ( \/ [ ^ " ] * ?) " / g,
3132 ( match , src ) => {
32- if ( ! src . startsWith ( '/trustyai-blog/' ) ) {
33- const newSrc = `${ baseUrl } ${ src } ` ;
33+ if ( ! src . startsWith ( siteUrl ) ) {
34+ const newSrc = `${ siteUrl } ${ src } ` ;
3435 console . log ( `Transforming HTML img src: ${ src } -> ${ newSrc } ` ) ;
3536 return `src="${ newSrc } "` ;
3637 }
@@ -44,7 +45,7 @@ function remarkBaseUrl() {
4445
4546// https://astro.build/config
4647export default defineConfig ( {
47- site : 'https://blog.trustyai.org' ,
48+ site : siteUrl ,
4849 base : baseUrl ,
4950 integrations : [ mdx ( ) , sitemap ( ) ] ,
5051 markdown : {
0 commit comments