0

在这里,我使用 react-helmet 共享内容。但我坚持共享图像。它只显示共享 url 上定义的默认内容,但我在元标记上定义的内容不起作用。这是我的代码。我如何分享图像。在此先感谢。

头盔.js

import { Helmet } from "react-helmet";
export default function HelmetMetaData(props) {
   let currentUrl = "http://localhost:3000" ;
   let quote = props.quote !== undefined ? props.quote : "";
   let title = props.title !== undefined ? props.title : "react share ";
   let image = props.image !== undefined ? props.image : "https://storage.googleapis.com/cmperstribe_storage_usha/Banner/IMG_3640.JPG";
   let description = props.description !== undefined ? props.description  : "orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recentlwith desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
   let hashtag = props.hashtag !== undefined ? props.hashtag : "#camperstribe";
return (
 <Helmet>
     <title>{title}</title>
     <meta charset="utf-8" />
     <meta http-equiv="X-UA-Compatible" content="IE=edge" />
     <meta name="csrf_token" content="" />
     <meta property="type" content="website" />
     <meta property="url" content={currentUrl} />
     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
     <meta name="msapplication-TileColor" content="#ffffff" />
     <meta name="msapplication-TileImage" content="/ms-icon-144x144.png" />
     <meta name="theme-color" content="#ffffff" />
     <meta name="_token" content="" />
     <meta name="robots" content="noodp" />
     <meta property="title" content={title} />
     <meta property="quote" content={quote} />
     <meta name="description" content={description} />
     <meta property="image" content={image} />
     <meta property="og:locale" content="en_US" />
     <meta property="og:type" content="website" />
     <meta property="og:title" content={title} />
     <meta property="og:quote" content={quote} />
     <meta property="og:hashtag" content={hashtag} />
     <meta property="og:image" content={image} />
     <meta content="image/*" property="og:image:type" />
     <meta property="og:url" content={currentUrl} />
     <meta property="og:site_name" content="CampersTribe" />
     <meta property="og:description" content={description} />    </Helmet>
);
}

索引.js

<div>
        <Head>
          <title>facebook clone  next js</title>
          <HelmetMetaData></HelmetMetaData>
        </Head>
      <div className="h-screen bg-gray-100 overflow-hidden">
      <Header session={session}/>
      <main className="flex">
      <Sidebar session={session}/>
      <Feed posts={posts}myId={myId}session={session}/>
     <Share/>
      </main>
      </div>
      </div>

分享.js

   <FacebookShareButton
                url={"https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=959514238108782&height=50&width=50&ext=1639482313&hash=AeQW9JjFvK4otTde01E"}
                className="Demo__some-network__share-button"
                >
                <FacebookIcon size={32} round />
                </FacebookShareButton>
                <FacebookShareCount url={"https://peing.net/ja/"}>{shareCount => <span className="myShareCountWrapper">{shareCount}</span>}</FacebookShareCount>
                <br />
                <WhatsappShareButton
                title={"whatsapp"}
                url={"https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=959514238108782&height=50&width=50&ext=1639482313&hash=AeQW9JjFvK4otTde01E"}
                hashtags={["reactShare","reactJs"]}
                >
            <WhatsappIcon size={32} round />
            </WhatsappShareButton>
            <TwitterShareButton
            title={"test"}
            url={"https://peing.net/ja/"}
            hashtags={["hashtag1", "hashtag2"]}>
            <TwitterIcon size={32} round></TwitterIcon>

            </TwitterShareButton>
4

0 回答 0