Reactjs 带有动态标题和描述的Whatsapp共享
我有一个使用React构建的网站,它位于www.url.com域下,我在index.html上设置了以下metaReactjs 带有动态标题和描述的Whatsapp共享,reactjs,sharethis,Reactjs,Sharethis,我有一个使用React构建的网站,它位于www.url.com域下,我在index.html上设置了以下meta <meta name="description" content="My description"> <meta property="og:title" content="My title" /> <meta property="og:url" content="https://www.url.com" /> <meta property="
<meta name="description" content="My description">
<meta property="og:title" content="My title" />
<meta property="og:url" content="https://www.url.com" />
<meta property="og:description" content="My description">
<meta property="og:image" content="https://www.myimage.com">
<meta property="og:type" content="website" />
我的网站中包含帖子,每个帖子都有其独特的URL(如www.URL.com/post/thispost)、标题、描述和图片。我使用ShareThisReactJS插件()为每篇文章创建共享按钮,并进行以下设置
<InlineShareButtons
config={{
alignment: 'center', // alignment of buttons (left, center, right)
color: 'social', // set the color of buttons (social, white)
enabled: true, // show/hide buttons (true, false)
font_size: 14, // font size for the buttons
labels: 'cta', // button labels (cta, counts, null)
language: 'en', // which language to use (see LANGUAGES)
networks: [ // which networks to include (see SHARING NETWORKS)
'whatsapp',
'facebook'
],
padding: 12, // padding within buttons (INTEGER)
radius: 4, // the corner radius on each button (INTEGER)
show_total: false,
size: 40, // the size of each button (INTEGER)
// OPTIONAL PARAMETERS
url: window.location.href, // (defaults to current url)
description: {description}, // (defaults to og:description or twitter:description)
title: {title}, // (defaults to og:title or twitter:title)
}}
/>
其中描述和标题是每个帖子的内容和标题。因为每篇文章都是一个弹出窗口,标题和描述只有在打开弹出窗口时才可用,所以我将其设计为只在弹出窗口打开时初始化InlineShareButtons
但这里的问题是,当我分享这篇文章时,它并没有以我想要的方式显示描述和标题。相反,每当我试图分享每篇文章时,它都会显示index.html上meta标记的描述和标题
有没有办法做到这一点,这样当我分享任何帖子时,它会使用帖子上的标题和描述