@@ -10,7 +10,7 @@ import { getTimeSincePublished, getBlogPostBySlug, getAllBlogPostSlugs } from '@
1010import { getBlogAltText } from '@/utils/imageValidation' ;
1111import BlogImageWithLoader from '@/Components/UI/BlogImageWithLoader' ;
1212import { getArticleSchema , getBreadcrumbSchema } from '@/utils/structuredData' ;
13- import { baseURL } from '@/utils/api ' ;
13+ import { getBlogBaseURL , getBlogPath } from '@/utils/url ' ;
1414
1515export const revalidate = 0 ;
1616
@@ -62,7 +62,7 @@ export async function generateMetadata({ params }: BlogPostPageProps): Promise<M
6262 } else {
6363 excerpt = post . body ?. [ 0 ] ?. children ?. [ 0 ] ?. text ?. substring ( 0 , 160 ) || '' ;
6464 }
65-
65+
6666 const metaDescription = excerpt || `Read about ${ post . title } ` ;
6767
6868 return {
@@ -96,15 +96,15 @@ export async function generateMetadata({ params }: BlogPostPageProps): Promise<M
9696 openGraph : {
9797 title : post . title ,
9898 description : excerpt ,
99- url : `${ baseURL } /blogs /${ post . slug . current } ` ,
100- images : post . image ?. asset ?. url
101- ? [ post . image . asset . url ]
99+ url : `${ getBlogBaseURL ( ) } /${ post . slug . current } ` ,
100+ images : post . image ?. asset ?. url
101+ ? [ post . image . asset . url ]
102102 : [ {
103- url : ` ${ baseURL } / UtkarshSorathia.webp` ,
104- alt : post . title ,
105- width : 1200 ,
106- height : 630 ,
107- } ] ,
103+ url : 'https://utkarshsorathia.in/ UtkarshSorathia.webp' ,
104+ alt : post . title ,
105+ width : 1200 ,
106+ height : 630 ,
107+ } ] ,
108108 type : 'article' ,
109109 publishedTime : post . publishedAt ,
110110 modifiedTime : post . _updatedAt ,
@@ -116,13 +116,13 @@ export async function generateMetadata({ params }: BlogPostPageProps): Promise<M
116116 card : 'summary_large_image' ,
117117 title : post . title ,
118118 description : excerpt ,
119- images : post . image ?. asset ?. url
120- ? [ post . image . asset . url ]
121- : [ ` ${ baseURL } / UtkarshSorathia.webp` ] ,
119+ images : post . image ?. asset ?. url
120+ ? [ post . image . asset . url ]
121+ : [ 'https://utkarshsorathia.in/ UtkarshSorathia.webp' ] ,
122122 creator : '@utkarshsor03' ,
123123 } ,
124124 alternates : {
125- canonical : `${ baseURL } /blogs /${ post . slug . current } ` ,
125+ canonical : `${ getBlogBaseURL ( ) } /${ post . slug . current } ` ,
126126 } ,
127127 } ;
128128}
@@ -155,13 +155,13 @@ export default async function BlogPostPage({ params }: BlogPostPageProps) {
155155 if ( block . _type === 'block' ) {
156156 const style = block . style || 'normal' ;
157157 const listItem = block . listItem ;
158-
158+
159159 let text = '' ;
160-
160+
161161 if ( block . children && Array . isArray ( block . children ) ) {
162162 block . children . forEach ( ( child : any ) => {
163163 let childText = String ( child ?. text || '' ) ;
164-
164+
165165 // Apply marks from the child
166166 if ( child ?. marks && Array . isArray ( child . marks ) ) {
167167 // Check for strong
@@ -177,7 +177,7 @@ export default async function BlogPostPage({ params }: BlogPostPageProps) {
177177 childText = `\`${ childText } \`` ;
178178 }
179179 }
180-
180+
181181 text += childText ;
182182 } ) ;
183183 }
@@ -201,23 +201,23 @@ export default async function BlogPostPage({ params }: BlogPostPageProps) {
201201 } ;
202202
203203 // Convert body to markdown string if needed
204- const bodyMarkdown = typeof post . body === 'string'
205- ? post . body
204+ const bodyMarkdown = typeof post . body === 'string'
205+ ? post . body
206206 : convertPortableTextToMarkdown ( post . body ) ;
207207
208208 // Get image URL for structured data
209- const imageUrl = post . image ?. asset ?. url || ` ${ baseURL } / UtkarshSorathia.webp` ;
209+ const imageUrl = post . image ?. asset ?. url || 'https://utkarshsorathia.in/ UtkarshSorathia.webp' ;
210210 const excerpt = typeof post . body === 'string'
211211 ? post . body
212- . replace ( / ^ # { 1 , 6 } \s + / gm, '' )
213- . replace ( / \* \* ( [ ^ * ] + ) \* \* / g, '$1' )
214- . replace ( / \* ( [ ^ * ] + ) \* / g, '$1' )
215- . replace ( / ` ( [ ^ ` ] + ) ` / g, '$1' )
216- . replace ( / \[ ( [ ^ \] ] + ) \] \( [ ^ \) ] + \) / g, '$1' )
217- . replace ( / \[ | \] | \( | \) | ` | # | \* / g, '' )
218- . replace ( / \s + / g, ' ' )
219- . trim ( )
220- . substring ( 0 , 160 )
212+ . replace ( / ^ # { 1 , 6 } \s + / gm, '' )
213+ . replace ( / \* \* ( [ ^ * ] + ) \* \* / g, '$1' )
214+ . replace ( / \* ( [ ^ * ] + ) \* / g, '$1' )
215+ . replace ( / ` ( [ ^ ` ] + ) ` / g, '$1' )
216+ . replace ( / \[ ( [ ^ \] ] + ) \] \( [ ^ \) ] + \) / g, '$1' )
217+ . replace ( / \[ | \] | \( | \) | ` | # | \* / g, '' )
218+ . replace ( / \s + / g, ' ' )
219+ . trim ( )
220+ . substring ( 0 , 160 )
221221 : post . body ?. [ 0 ] ?. children ?. [ 0 ] ?. text ?. substring ( 0 , 160 ) || '' ;
222222
223223 // Generate structured data
@@ -231,9 +231,9 @@ export default async function BlogPostPage({ params }: BlogPostPageProps) {
231231 ) ;
232232
233233 const breadcrumbSchema = getBreadcrumbSchema ( [
234- { name : 'Home' , url : baseURL } ,
235- { name : 'Blog' , url : ` ${ baseURL } /blogs` } ,
236- { name : post . title , url : `${ baseURL } /blogs /${ post . slug . current } ` } ,
234+ { name : 'Home' , url : 'https://utkarshsorathia.in' } ,
235+ { name : 'Blog' , url : getBlogBaseURL ( ) } ,
236+ { name : post . title , url : `${ getBlogBaseURL ( ) } /${ post . slug . current } ` } ,
237237 ] ) ;
238238
239239 return (
@@ -250,15 +250,15 @@ export default async function BlogPostPage({ params }: BlogPostPageProps) {
250250 __html : JSON . stringify ( breadcrumbSchema ) ,
251251 } }
252252 />
253- < ResponsiveBox
253+ < ResponsiveBox
254254 classNames = "min-h-screen dark:bg-[var(--bgColor)] bg-[var(--bgColor)] dark:bg-grid-white/[0.1] bg-grid-white/[0.1] items-center justify-center lg:px-40"
255255 id = "blog-post"
256256 >
257257 < ConstrainedBox classNames = "px-4 py-16" >
258258 { /* Back Button */ }
259259 < div className = "mb-6 sm:mb-8" >
260260 < Link
261- href = "/blogs "
261+ href = "/"
262262 className = "inline-flex items-center text-[var(--primaryColor)] hover:text-[var(--primaryColor)]/80 transition-colors text-sm sm:text-base"
263263 >
264264 < ArrowLeft className = "w-4 h-4 mr-2" />
@@ -320,7 +320,7 @@ export default async function BlogPostPage({ params }: BlogPostPageProps) {
320320 </ p >
321321 </ div >
322322 < Link
323- href = "/blogs "
323+ href = "/"
324324 className = "inline-flex items-center px-4 sm:px-6 py-2 sm:py-3 bg-gradient-to-r from-[var(--primaryColor)] to-indigo-600 hover:from-indigo-600 hover:to-[var(--primaryColor)] text-white rounded-[var(--borderRadius)] transition-all duration-300 text-sm sm:text-base whitespace-nowrap"
325325 >
326326 Read More Blogs
0 commit comments