Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
feat(components): allow globally show/hide page metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
filipowm committed Jun 4, 2020
1 parent 3b3294f commit d8a905c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
1 change: 1 addition & 0 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ features:
enabled: true
arrowKeyNavigation: true
scrollTop: true
showMetadata: true
2 changes: 1 addition & 1 deletion content/index.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Gitbook Template"
skipMetadata: true
showMetadata: false
editable: false
skipToC: true
---
Expand Down
2 changes: 1 addition & 1 deletion gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports.createSchemaCustomization = ({ actions }) => {
type MdxFrontmatter {
skipToC: Boolean
editable: Boolean
skipMetadata: Boolean
showMetadata: Boolean
showPreviousNext: Boolean
metaDescription: String
metaTitle: String
Expand Down
33 changes: 17 additions & 16 deletions src/templates/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,22 @@ export default class MDXRuntimeTest extends React.Component {
''
)}
</TitleWrapper>
{mdx.frontmatter.skipMetadata ? (
''
) : (
<div css={{ display: 'block' }}>
{mdx.parent.fields ? (
<LastUpdated
time={mdx.parent.fields.gitLogLatestDate}
name={mdx.parent.fields.gitLogLatestAuthorName}
email={mdx.parent.fields.gitLogLatestAuthorEmail}
/>
) : (
''
)}
<ReadingTime time={mdx.timeToRead * 2} />
</div>
{(config.features.showMetadata === true && mdx.frontmatter.showMetadata !== false)
|| mdx.frontmatter.showMetadata === true ? (
<div css={{ display: 'block' }}>
{mdx.parent.fields ? (
<LastUpdated
time={mdx.parent.fields.gitLogLatestDate}
name={mdx.parent.fields.gitLogLatestAuthorName}
email={mdx.parent.fields.gitLogLatestAuthorEmail}
/>
) : (
''
)}
<ReadingTime time={mdx.timeToRead * 2} />
</div>
) : (
''
)}
</PageTitle>
<ContentWrapper>
Expand Down Expand Up @@ -210,7 +211,7 @@ export const pageQuery = graphql`
frontmatter {
metaTitle
metaDescription
skipMetadata
showMetadata
editable
showPreviousNext
skipToC
Expand Down

0 comments on commit d8a905c

Please sign in to comment.