mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
Blog enhancements (#80)
* Small CSS adjustments. * Blog adjustments. * Add support for Prism in the blog
This commit is contained in:
parent
a484893c4f
commit
45f6ef8fd9
7 changed files with 80 additions and 2 deletions
|
@ -55,6 +55,16 @@ class BlogPost extends React.Component {
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
} else if (post.authorImage) {
|
||||||
|
return (
|
||||||
|
<div className="authorPhoto">
|
||||||
|
<a href={post.authorURL} target="_blank">
|
||||||
|
<img
|
||||||
|
src={post.authorImage}
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -99,6 +109,8 @@ class BlogPost extends React.Component {
|
||||||
<a href={post.authorURL} target="_blank">
|
<a href={post.authorURL} target="_blank">
|
||||||
{post.author}
|
{post.author}
|
||||||
</a>
|
</a>
|
||||||
|
<br />
|
||||||
|
{post.authorTitle}
|
||||||
</p>
|
</p>
|
||||||
{this.renderTitle()}
|
{this.renderTitle()}
|
||||||
<p className="post-meta">
|
<p className="post-meta">
|
||||||
|
|
|
@ -15,6 +15,40 @@ const Site = require("./Site.js");
|
||||||
|
|
||||||
// used for entire blog posts, i.e., each written blog article with sidebar with site header/footer
|
// used for entire blog posts, i.e., each written blog article with sidebar with site header/footer
|
||||||
class BlogPostLayout extends React.Component {
|
class BlogPostLayout extends React.Component {
|
||||||
|
|
||||||
|
renderSocialButtons() {
|
||||||
|
const post = this.props.metadata;
|
||||||
|
|
||||||
|
const fbLike = this.props.config.facebookAppId ?
|
||||||
|
<div
|
||||||
|
className="fb-like"
|
||||||
|
data-layout="standard"
|
||||||
|
data-share="true"
|
||||||
|
data-width="225"
|
||||||
|
data-show-faces="false">
|
||||||
|
</div>
|
||||||
|
: null;
|
||||||
|
|
||||||
|
const twitterShare = this.props.config.twitter ?
|
||||||
|
<a href="https://twitter.com/share" className="twitter-share-button" data-text={post.title} data-url={this.props.config.url + this.props.config.baseUrl + "blog/" + post.path} data-related={this.props.config.twitter} data-via={post.authorTwitter} data-show-count="false">Tweet</a>
|
||||||
|
: null;
|
||||||
|
|
||||||
|
if (!fbLike && !twitterShare) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<aside className="entry-share">
|
||||||
|
<div className="social-buttons">
|
||||||
|
{fbLike}
|
||||||
|
{twitterShare}
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Site
|
<Site
|
||||||
|
@ -39,6 +73,7 @@ class BlogPostLayout extends React.Component {
|
||||||
language={"en"}
|
language={"en"}
|
||||||
config={this.props.config}
|
config={this.props.config}
|
||||||
/>
|
/>
|
||||||
|
{this.renderSocialButtons()}
|
||||||
</div>
|
</div>
|
||||||
<div className="blog-recent">
|
<div className="blog-recent">
|
||||||
<a
|
<a
|
||||||
|
|
|
@ -18,7 +18,7 @@ class BlogSidebar extends React.Component {
|
||||||
const contents = [
|
const contents = [
|
||||||
{
|
{
|
||||||
name: "Recent Posts",
|
name: "Recent Posts",
|
||||||
links: MetadataBlog
|
links: MetadataBlog.slice(0, 5)
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
const title = this.props.current && this.props.current.title;
|
const title = this.props.current && this.props.current.title;
|
||||||
|
|
|
@ -10,10 +10,12 @@
|
||||||
const Marked = require("./Marked.js");
|
const Marked = require("./Marked.js");
|
||||||
const Container = require("./Container.js");
|
const Container = require("./Container.js");
|
||||||
const GridBlock = require("./GridBlock.js");
|
const GridBlock = require("./GridBlock.js");
|
||||||
|
const Prism = require("./Prism.js");
|
||||||
|
|
||||||
// collection of other components to provide to users
|
// collection of other components to provide to users
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Marked: Marked,
|
Marked: Marked,
|
||||||
Container: Container,
|
Container: Container,
|
||||||
GridBlock: GridBlock
|
GridBlock: GridBlock,
|
||||||
|
Prism: Prism
|
||||||
};
|
};
|
||||||
|
|
|
@ -75,6 +75,21 @@ class Site extends React.Component {
|
||||||
`
|
`
|
||||||
}}
|
}}
|
||||||
/>}
|
/>}
|
||||||
|
{this.props.config.facebookAppId &&
|
||||||
|
<script
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: `window.fbAsyncInit = function() {FB.init({appId:'${this.props.config.facebookAppId}',xfbml:true,version:'v2.7'});};(function(d, s, id){var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) {return;}js = d.createElement(s); js.id = id;js.src = '//connect.facebook.net/en_US/sdk.js';fjs.parentNode.insertBefore(js, fjs);}(document, 'script','facebook-jssdk'));
|
||||||
|
`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
{this.props.config.twitter &&
|
||||||
|
<script
|
||||||
|
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'));`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
{this.props.config.algolia &&
|
{this.props.config.algolia &&
|
||||||
(this.props.config.algolia.algoliaOptions
|
(this.props.config.algolia.algoliaOptions
|
||||||
? <script
|
? <script
|
||||||
|
|
0
lib/rename-version.js
Normal file → Executable file
0
lib/rename-version.js
Normal file → Executable file
|
@ -1657,6 +1657,9 @@ table tr th {
|
||||||
.blog-recent {
|
.blog-recent {
|
||||||
height: 40px;
|
height: 40px;
|
||||||
}
|
}
|
||||||
|
.blogContainer .lonePost {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-link {
|
.header-link {
|
||||||
|
@ -1980,3 +1983,14 @@ footer .copyright {
|
||||||
color: rgba(255, 255, 255, 0.4);
|
color: rgba(255, 255, 255, 0.4);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.entry-share {
|
||||||
|
padding: 36px 0;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 768px) {
|
||||||
|
.entry-share {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue