Skip to content

Commit

Permalink
feat: add disableEditLink, disableUpdateTime frontmatters. You can di…
Browse files Browse the repository at this point in the history
…sable theme for certain page.
  • Loading branch information
wangyi7099 committed Aug 15, 2019
1 parent f1a0bb4 commit 83cd8e7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/antdsite/lib/gatsby/createSchemaCustomization.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ module.exports = ({ actions }) => {
disabled: Boolean
link: String
important: Boolean
disableEditLink: Boolean
disableUpdateTime: Boolean
home: Boolean
heroImage: String
actionText: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class Article extends React.PureComponent {
}
} = this.context;

const { subtitle } = currentPageInfo.frontmatter;
const { subtitle, disableEditLink, disableUpdateTime } = currentPageInfo.frontmatter;
const { path, modifiedTime, avatarList } = currentPageInfo.fields;
const noAvatar = !showAvatarList || !avatarList || !avatarList.length;
const editPath = this.getEditLink(editLink, docsRepo || repo, docsBranch, path);
Expand All @@ -69,7 +69,7 @@ export default class Article extends React.PureComponent {
this.node = node;
}}
>
{(docsRepo || repo) && editLinkText && editLinks ? (
{(docsRepo || repo) && editLinkText && editLinks && !disableEditLink ? (
<h1>
{currentPageTitle}
{!subtitle ? null : <span className="subtitle">{subtitle}</span>}
Expand All @@ -78,7 +78,7 @@ export default class Article extends React.PureComponent {
</h1>
) : null}

{lastUpdated && (
{lastUpdated && !disableUpdateTime && (
<div className={`modifiedTime ${noAvatar ? 'modifiedTimeLeft' : ''}`}>
{!noAvatar && <AvatarList avatarList={avatarList} />}
{lastUpdated} {moment(modifiedTime).format('YYYY-MM-DD HH:mm:SS')}
Expand Down
4 changes: 4 additions & 0 deletions packages/antdsite/src/templates/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export interface IGraphqlFrontmatterData {
link?: string;
subtitle?: string;
editLink?: string;
disableEditLink?: Boolean;
disableUpdateTime?: Boolean;
}

export interface IMarkDownFields {
Expand Down Expand Up @@ -157,6 +159,8 @@ export const pageQuery = graphql`
title
}
editLink
disableUpdateTime
disableEditLink
}
fields {
modifiedTime
Expand Down

0 comments on commit 83cd8e7

Please sign in to comment.