@@ -10,6 +10,9 @@ import TOC from '@theme/TOC';
10
10
import Unlisted from '@theme/Unlisted' ;
11
11
import GiscusComponent from '@site/src/components/GiscusComponent' ;
12
12
import { PostPaginator } from '@site/src/components/blog/post-paginator' ;
13
+ import { LinkedinShareButton , RedditShareButton , TwitterShareButton , RedditIcon , LinkedinIcon } from 'react-share' ;
14
+ import { Twitter } from './icons' ;
15
+ import useDocusaurusContext from '@docusaurus/useDocusaurusContext' ;
13
16
14
17
function getMultipleRandomPosts ( relatedPosts , number ) {
15
18
// Create a copy of the original array to avoid modifying it
@@ -53,9 +56,8 @@ function getMultipleRandomPosts(relatedPosts, number) {
53
56
54
57
function BlogPostPageContent ( { children } ) {
55
58
const { metadata, toc } = useBlogPost ( ) ;
56
- const { relatedPosts } = metadata ;
57
59
58
- const { nextItem, prevItem, frontMatter, unlisted } = metadata ;
60
+ const { relatedPosts , nextItem, prevItem, frontMatter, unlisted, permalink , title , description } = metadata ;
59
61
const {
60
62
hide_table_of_contents : hideTableOfContents ,
61
63
toc_min_heading_level : tocMinHeadingLevel ,
@@ -65,6 +67,9 @@ function BlogPostPageContent({ children }) {
65
67
const randomThreeRelatedPosts = getMultipleRandomPosts ( relatedPosts , 3 ) ;
66
68
67
69
console . log ( 'relatedPosts' , relatedPosts ) ;
70
+ const {
71
+ siteConfig : { url } ,
72
+ } = useDocusaurusContext ( ) ;
68
73
69
74
return (
70
75
< BlogLayout
@@ -77,6 +82,36 @@ function BlogPostPageContent({ children }) {
77
82
{ unlisted && < Unlisted /> }
78
83
79
84
< BlogPostItem > { children } </ BlogPostItem >
85
+ < div className = "flex items-center gap-3 pt-10 not-prose" >
86
+ < span className = "text-base" > Share on</ span >
87
+ < TwitterShareButton
88
+ windowWidth = { 750 }
89
+ windowHeight = { 800 }
90
+ url = { url + permalink }
91
+ className = "flex"
92
+ title = { title }
93
+ >
94
+ < Twitter width = { 36 } height = { 36 } />
95
+ </ TwitterShareButton >
96
+ < RedditShareButton
97
+ className = "flex"
98
+ windowWidth = { 750 }
99
+ windowHeight = { 600 }
100
+ url = { url + permalink }
101
+ title = { title }
102
+ >
103
+ < RedditIcon size = { 36 } round />
104
+ </ RedditShareButton >
105
+ < LinkedinShareButton
106
+ url = { url + permalink }
107
+ title = { title }
108
+ source = { url }
109
+ summary = { description }
110
+ className = "flex"
111
+ >
112
+ < LinkedinIcon size = { 36 } round />
113
+ </ LinkedinShareButton >
114
+ </ div >
80
115
< PostPaginator title = "Related Articles" posts = { randomThreeRelatedPosts } > </ PostPaginator >
81
116
< GiscusComponent />
82
117
{ ( nextItem || prevItem ) && < BlogPostPaginator nextItem = { nextItem } prevItem = { prevItem } /> }
0 commit comments