Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hide_title metadata that hides the title text on the top of the doc #540

Merged
merged 7 commits into from
Apr 12, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/api-doc-markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Documents use the following markdown header fields that are enclosed by a line `

`title`: The title of your document. If this field is not present, the document's `title` will default to its `id`.

`hide_title`: Whether to hide the title at the top of the doc.

`sidebar_label`: The text shown in the document sidebar for this document. If this field is not present, the document's `sidebar_label` will default to its `title`.

For example:
Expand Down
3 changes: 2 additions & 1 deletion lib/core/Doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ class Doc extends React.Component {
</a>
);
}

return (
<div className="post">
<header className="postHeader">
{editLink}
<h1>{this.props.title}</h1>
{this.props.hideTitle && <h1>{this.props.title}</h1>}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait. Shouldn't this be

!this.props.hideTitle

We only want to show this if we don't have hideTitle, right?

</header>
<article>
<MarkdownBlock>{this.props.content}</MarkdownBlock>
Expand Down
23 changes: 8 additions & 15 deletions lib/core/DocsLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@ class DocsLayout extends React.Component {
if (this.props.Doc) {
DocComponent = this.props.Doc;
}
const title = i18n
? translation[this.props.metadata.language]['localized-strings'][
this.props.metadata.localized_id
] || this.props.metadata.title
: this.props.metadata.title;
return (
<Site
config={this.props.config}
className="sideNavVisible doc"
title={
i18n
? translation[this.props.metadata.language]['localized-strings'][
this.props.metadata.localized_id
] || this.props.metadata.title
: this.props.metadata.title
}
title={title}
description={content.trim().split('\n')[0]}
language={metadata.language}
version={metadata.version}
Expand All @@ -46,14 +45,8 @@ class DocsLayout extends React.Component {
content={content}
config={this.props.config}
source={metadata.source}
title={
i18n
? translation[this.props.metadata.language][
'localized-strings'
][this.props.metadata.localized_id] ||
this.props.metadata.title
: this.props.metadata.title
}
hideTitle={this.props.metadata.hide_title}
title={title}
version={metadata.version}
language={metadata.language}
/>
Expand Down
Loading