mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-12 22:38:04 +02:00
Enhance footer with Facebook and Twitter buttons (#666)
* enhance footer with social media buttons * Update api-site-config.md * Update Footer.js * fix minor issue on social-footer * update facebookAppId description in api-site-config * rm heading & pad footer social button * Update api-site-config.md
This commit is contained in:
parent
f9a09072e3
commit
f8521c2fe1
5 changed files with 52 additions and 25 deletions
|
@ -93,7 +93,7 @@ customDocsPath: 'website-docs'
|
||||||
|
|
||||||
`editUrl` - url for editing docs, usage example: `editUrl + 'en/doc1.md'`. If this field is omitted, there will be no "Edit this Doc" button for each document.
|
`editUrl` - url for editing docs, usage example: `editUrl + 'en/doc1.md'`. If this field is omitted, there will be no "Edit this Doc" button for each document.
|
||||||
|
|
||||||
`facebookAppId` - If you want Facebook Like/Share buttons at the bottom of your blog posts, provide a [Facebook application id](https://www.facebook.com/help/audiencenetwork/804209223039296), and the buttons will show up on all blog posts.
|
`facebookAppId` - If you want Facebook Like/Share buttons in the footer and at the bottom of your blog posts, provide a [Facebook application id](https://www.facebook.com/help/audiencenetwork/804209223039296).
|
||||||
|
|
||||||
`facebookPixelId` - [Facebook Pixel](https://www.facebook.com/business/a/facebook-pixel) ID to track page views.
|
`facebookPixelId` - [Facebook Pixel](https://www.facebook.com/business/a/facebook-pixel) ID to track page views.
|
||||||
|
|
||||||
|
@ -154,6 +154,8 @@ h1 {
|
||||||
|
|
||||||
`twitter` - Set this to `true` if you want a Twitter social button to appear at the bottom of your blog posts.
|
`twitter` - Set this to `true` if you want a Twitter social button to appear at the bottom of your blog posts.
|
||||||
|
|
||||||
|
`twitterUsername` - If you want a Twitter follow button at the bottom of your page, provide a Twitter username to follow. For example: `docusaurus`.
|
||||||
|
|
||||||
`twitterImage` - Local path to your Twitter card image (e.g., `img/myImage.png`). This image will show up on the Twitter card when your site is shared on Twitter.
|
`twitterImage` - Local path to your Twitter card image (e.g., `img/myImage.png`). This image will show up on the Twitter card when your site is shared on Twitter.
|
||||||
|
|
||||||
`useEnglishUrl` - If you do not have [translations](guides-translation.md) enabled (e.g., by having a `languages.js` file), but still want a link of the form `/docs/en/doc.html` (with the `en`), set this to `true`.
|
`useEnglishUrl` - If you do not have [translations](guides-translation.md) enabled (e.g., by having a `languages.js` file), but still want a link of the form `/docs/en/doc.html` (with the `en`), set this to `true`.
|
||||||
|
@ -231,6 +233,7 @@ const siteConfig = {
|
||||||
facebookAppId: '1615782811974223',
|
facebookAppId: '1615782811974223',
|
||||||
facebookPixelId: '352490515235776',
|
facebookPixelId: '352490515235776',
|
||||||
twitter: 'true',
|
twitter: 'true',
|
||||||
|
twitterUsername: 'docusaurus',
|
||||||
twitterImage: 'img/docusaurus.png',
|
twitterImage: 'img/docusaurus.png',
|
||||||
ogImage: 'img/docusaurus.png',
|
ogImage: 'img/docusaurus.png',
|
||||||
};
|
};
|
||||||
|
|
|
@ -113,7 +113,7 @@ class Site extends React.Component {
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{this.props.config.twitter && (
|
{(this.props.config.twitter || this.props.config.twitterUsername) && (
|
||||||
<script
|
<script
|
||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
__html: `window.twttr=(function(d,s, id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src='https://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js, fjs);t._e = [];t.ready = function(f) {t._e.push(f);};return t;}(document, 'script', 'twitter-wjs'));`,
|
__html: `window.twttr=(function(d,s, id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src='https://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js, fjs);t._e = [];t.ready = function(f) {t._e.push(f);};return t;}(document, 'script', 'twitter-wjs'));`,
|
||||||
|
|
|
@ -1826,6 +1826,10 @@ footer .copyright {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
footer .social {
|
||||||
|
padding: 5px 0;
|
||||||
|
}
|
||||||
|
|
||||||
.entry-share {
|
.entry-share {
|
||||||
padding: 36px 0;
|
padding: 36px 0;
|
||||||
display: block;
|
display: block;
|
||||||
|
|
|
@ -8,21 +8,49 @@ const PropTypes = require('prop-types');
|
||||||
|
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
|
|
||||||
const GitHubButton = props => (
|
const SocialFooter = props => (
|
||||||
<a
|
<div>
|
||||||
className="github-button" // part of the https://buttons.github.io/buttons.js script in siteConfig.js
|
<h5>More</h5>
|
||||||
href={`https://github.com/${props.config.organizationName}/${props.config.projectName}`}
|
<div className="social">
|
||||||
data-icon="octicon-star"
|
<a
|
||||||
data-count-href={`/${props.config.organizationName}/${props.config.projectName}/stargazers`}
|
className="github-button" // part of the https://buttons.github.io/buttons.js script in siteConfig.js
|
||||||
data-show-count="true"
|
href={`https://github.com/${props.config.organizationName}/${
|
||||||
data-count-aria-label="# stargazers on GitHub"
|
props.config.projectName
|
||||||
aria-label="Star this project on GitHub"
|
}`}
|
||||||
>
|
data-count-href={`/${props.config.organizationName}/${
|
||||||
Star
|
props.config.projectName
|
||||||
</a>
|
}/stargazers`}
|
||||||
|
data-show-count="true"
|
||||||
|
data-count-aria-label="# stargazers on GitHub"
|
||||||
|
aria-label="Star this project on GitHub">
|
||||||
|
{props.config.projectName}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{props.config.twitterUsername && (
|
||||||
|
<div className="social">
|
||||||
|
<a
|
||||||
|
href={`https://twitter.com/${props.config.twitterUsername}`}
|
||||||
|
className="twitter-follow-button">
|
||||||
|
Follow @{props.config.twitterUsername}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{props.config.facebookAppId && (
|
||||||
|
<div className="social">
|
||||||
|
<div
|
||||||
|
className="fb-like"
|
||||||
|
data-href={props.config.url}
|
||||||
|
data-layout="standard"
|
||||||
|
data-share="true"
|
||||||
|
data-width="225"
|
||||||
|
data-show-faces="false"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
GitHubButton.propTypes = {
|
SocialFooter.propTypes = {
|
||||||
config: PropTypes.object
|
config: PropTypes.object
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,17 +105,8 @@ class Footer extends React.Component {
|
||||||
>
|
>
|
||||||
User Showcase
|
User Showcase
|
||||||
</a>
|
</a>
|
||||||
<a href="https://twitter.com/docusaurus">
|
|
||||||
Twitter
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<h5>More</h5>
|
|
||||||
<a href="https://github.com/facebook/docusaurus">
|
|
||||||
GitHub
|
|
||||||
</a>
|
|
||||||
<GitHubButton config={this.props.config} />
|
|
||||||
</div>
|
</div>
|
||||||
|
<SocialFooter config={this.props.config} />
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
|
|
|
@ -50,6 +50,7 @@ const siteConfig = {
|
||||||
gaTrackingId: 'UA-44373548-31',
|
gaTrackingId: 'UA-44373548-31',
|
||||||
facebookAppId: '1615782811974223',
|
facebookAppId: '1615782811974223',
|
||||||
twitter: 'true',
|
twitter: 'true',
|
||||||
|
twitterUsername: 'docusaurus',
|
||||||
ogImage: 'img/docusaurus.png',
|
ogImage: 'img/docusaurus.png',
|
||||||
twitterImage: 'img/docusaurus.png',
|
twitterImage: 'img/docusaurus.png',
|
||||||
onPageNav: 'separate',
|
onPageNav: 'separate',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue