11import { Article } from "@/components/Article/Article" ;
2- import * as React from "react" ;
2+ import { useState , useEffect } from "react" ;
33import type { PageOpts } from "nextra" ;
44import dayjs from "dayjs" ;
55import { Button } from "@/components/ui/button" ;
@@ -10,8 +10,10 @@ import Link from "next/link";
1010import { Seo } from "@/components/Seo/Seo" ;
1111import { slugify } from "@/utility/slugify" ;
1212import { TypeSectionBlogTheme } from "@/src/types" ;
13+ import type { ReactNode } from "react" ;
1314
14- export function Read ( { pageOpts, themeConfig, children } : { pageOpts : PageOpts ; themeConfig : TypeSectionBlogTheme ; children : React . ReactNode ; } ) {
15+ export function Read ( { pageOpts, themeConfig, children } : { pageOpts : PageOpts ; themeConfig : TypeSectionBlogTheme ; children : ReactNode ; } ) {
16+ const [ domain , setDomain ] = useState < string > ( )
1517
1618 const { frontMatter } = pageOpts ;
1719
@@ -24,17 +26,21 @@ export function Read({ pageOpts, themeConfig, children }: { pageOpts: PageOpts;
2426 let getSite = settings ?. SiteURL
2527
2628 let getAuthorURL = frontMatter ?. author ?. url
27-
28- let getTagURL = Next_URL ( getSite ) + "tags/" + getTag
2929
30- let getRwebURL = Next_URL ( getSite ) + ( pageOpts . route . replace ( "/" , "" ) )
31-
30+ useEffect ( function ( ) {
31+ let getDomain = window . location . origin as string
32+ setDomain ( getDomain )
33+ } , [ ] )
34+
35+ let getTagURL = Next_URL ( getSite ) + "tags/" + getTag
36+
37+ let getRwebURL = domain + "/" + ( pageOpts . route . replace ( "/" , "" ) )
38+
3239 return (
3340 < >
3441
3542 < Seo pageOpts = { pageOpts } themeConfig = { themeConfig } />
3643
37-
3844 < div className = "px-3 sm:px-0 mx-auto my-6 print:block prose prose-pre:bg-primary-foreground prose-zinc sm:prose-sm md:prose-base lg:prose-lg xl:prose-xl 2xl:prose-2xl dark:prose-invert" >
3945
4046 < section className = "not-prose flex flex-row justify-between items-center" >
@@ -65,11 +71,11 @@ export function Read({ pageOpts, themeConfig, children }: { pageOpts: PageOpts;
6571 title = { getDate }
6672 >
6773 { getDate }
68- </ time > • < Link href = { getTagURL } className = "capitalize ml-2 hover:text-gray-600" > { frontMatter . tags [ 0 ] } </ Link >
74+ </ time > • < Link href = { getTagURL } className = "capitalize ml-2 hover:text-gray-600" > { getTag } </ Link >
6975 </ div >
7076
7177 < div className = "hidden sm:flex flex-row print:block" >
72-
78+
7379 < RWebShare
7480 data = { {
7581 text : frontMatter . description ,
@@ -78,9 +84,9 @@ export function Read({ pageOpts, themeConfig, children }: { pageOpts: PageOpts;
7884 } }
7985 onClick = { ( ) => console . log ( "shared successfully!" ) }
8086 >
81-
87+
8288 < Button aria-label = "Share a Post" variant = "ghost" size = "icon" >
83-
89+
8490 < Share2Icon className = "h-4 w-4" />
8591
8692 </ Button >
0 commit comments