Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions content/blog/how-to-build-feature-flags-react/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: "Build feature flags in React using the Context API: how to"
date: "2020-03-29T09:30:00Z"
last_modified: "2022-09-10T11:00:00Z"
description: "Learn how to build and leverage feature flags (or feature toggles) in React to improve both the development/release workflow and the user experience."
publication_status: published
---
Expand Down
2 changes: 1 addition & 1 deletion gatsby-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const config: GatsbyConfig = {
const page = JSON.parse(JSON.stringify(rest));
return {
url: path,
lastmod: page?.frontmatter?.date || new Date().toISOString(),
lastmod: page?.frontmatter?.last_modified || page?.frontmatter?.date || new Date().toISOString(),
};
},
},
Expand Down
23 changes: 22 additions & 1 deletion graphql-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ export type DirectoryCtimeArgs = {
export type Site = Node & {
buildTime?: Maybe<Scalars['Date']>;
siteMetadata?: Maybe<SiteSiteMetadata>;
port?: Maybe<Scalars['Int']>;
host?: Maybe<Scalars['String']>;
polyfill?: Maybe<Scalars['Boolean']>;
pathPrefix?: Maybe<Scalars['String']>;
jsxRuntime?: Maybe<Scalars['String']>;
Expand Down Expand Up @@ -694,6 +696,7 @@ export type Frontmatter = {
featured_image?: Maybe<File>;
order?: Maybe<Scalars['Int']>;
link?: Maybe<Scalars['String']>;
last_modified?: Maybe<Scalars['Date']>;
};


Expand All @@ -720,6 +723,14 @@ export type FrontmatterTo_DateArgs = {
locale?: InputMaybe<Scalars['String']>;
};


export type FrontmatterLast_ModifiedArgs = {
formatString?: InputMaybe<Scalars['String']>;
fromNow?: InputMaybe<Scalars['Boolean']>;
difference?: InputMaybe<Scalars['String']>;
locale?: InputMaybe<Scalars['String']>;
};

export type Fields = {
slug?: Maybe<Scalars['String']>;
};
Expand Down Expand Up @@ -850,6 +861,8 @@ export type QueryAllDirectoryArgs = {
export type QuerySiteArgs = {
buildTime?: InputMaybe<DateQueryOperatorInput>;
siteMetadata?: InputMaybe<SiteSiteMetadataFilterInput>;
port?: InputMaybe<IntQueryOperatorInput>;
host?: InputMaybe<StringQueryOperatorInput>;
polyfill?: InputMaybe<BooleanQueryOperatorInput>;
pathPrefix?: InputMaybe<StringQueryOperatorInput>;
jsxRuntime?: InputMaybe<StringQueryOperatorInput>;
Expand Down Expand Up @@ -1084,6 +1097,7 @@ export type FrontmatterFilterInput = {
featured_image?: InputMaybe<FileFilterInput>;
order?: InputMaybe<IntQueryOperatorInput>;
link?: InputMaybe<StringQueryOperatorInput>;
last_modified?: InputMaybe<DateQueryOperatorInput>;
};

export type FileFilterInput = {
Expand Down Expand Up @@ -1390,6 +1404,7 @@ export type FileFieldsEnum =
| 'childrenMarkdownRemark___frontmatter___featured_image___children'
| 'childrenMarkdownRemark___frontmatter___order'
| 'childrenMarkdownRemark___frontmatter___link'
| 'childrenMarkdownRemark___frontmatter___last_modified'
| 'childrenMarkdownRemark___fields___slug'
| 'childrenMarkdownRemark___excerpt'
| 'childrenMarkdownRemark___rawMarkdownBody'
Expand Down Expand Up @@ -1494,6 +1509,7 @@ export type FileFieldsEnum =
| 'childMarkdownRemark___frontmatter___featured_image___children'
| 'childMarkdownRemark___frontmatter___order'
| 'childMarkdownRemark___frontmatter___link'
| 'childMarkdownRemark___frontmatter___last_modified'
| 'childMarkdownRemark___fields___slug'
| 'childMarkdownRemark___excerpt'
| 'childMarkdownRemark___rawMarkdownBody'
Expand Down Expand Up @@ -2143,6 +2159,8 @@ export type SiteFieldsEnum =
| 'siteMetadata___author___summary'
| 'siteMetadata___siteUrl'
| 'siteMetadata___social___twitter'
| 'port'
| 'host'
| 'polyfill'
| 'pathPrefix'
| 'jsxRuntime'
Expand Down Expand Up @@ -2278,6 +2296,8 @@ export type SiteGroupConnectionGroupArgs = {
export type SiteFilterInput = {
buildTime?: InputMaybe<DateQueryOperatorInput>;
siteMetadata?: InputMaybe<SiteSiteMetadataFilterInput>;
port?: InputMaybe<IntQueryOperatorInput>;
host?: InputMaybe<StringQueryOperatorInput>;
polyfill?: InputMaybe<BooleanQueryOperatorInput>;
pathPrefix?: InputMaybe<StringQueryOperatorInput>;
jsxRuntime?: InputMaybe<StringQueryOperatorInput>;
Expand Down Expand Up @@ -3268,6 +3288,7 @@ export type MarkdownRemarkFieldsEnum =
| 'frontmatter___featured_image___internal___type'
| 'frontmatter___order'
| 'frontmatter___link'
| 'frontmatter___last_modified'
| 'fields___slug'
| 'excerpt'
| 'rawMarkdownBody'
Expand Down Expand Up @@ -3654,7 +3675,7 @@ export type BlogPostBySlugQueryVariables = Exact<{
}>;


export type BlogPostBySlugQuery = { site?: { siteMetadata?: { title?: string | null, author?: { name?: string | null } | null } | null } | null, markdownRemark?: { id: string, excerpt?: string | null, html?: string | null, frontmatter?: { title?: string | null, date?: any | null, description?: string | null } | null } | null, previous?: { fields?: { slug?: string | null } | null, frontmatter?: { title?: string | null } | null } | null, next?: { fields?: { slug?: string | null } | null, frontmatter?: { title?: string | null } | null } | null };
export type BlogPostBySlugQuery = { site?: { siteMetadata?: { title?: string | null, author?: { name?: string | null } | null } | null } | null, markdownRemark?: { id: string, excerpt?: string | null, html?: string | null, frontmatter?: { title?: string | null, date?: any | null, last_modified?: any | null, description?: string | null } | null } | null, previous?: { fields?: { slug?: string | null } | null, frontmatter?: { title?: string | null } | null } | null, next?: { fields?: { slug?: string | null } | null, frontmatter?: { title?: string | null } | null } | null };

export type GatsbyImageSharpFixedFragment = { base64?: string | null, width: number, height: number, src: string, srcSet: string };

Expand Down
8 changes: 8 additions & 0 deletions src/templates/BlogPost.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
color: var(--grey-3);
}

.last_updated {
font-size: 16px;
color: var(--grey-2);
border-radius: 5px;
padding: 10px;
background-color: var(--grey-4);
}

figcaption {
font-size: 16px;
color: var(--grey-3);
Expand Down
12 changes: 9 additions & 3 deletions src/templates/BlogPost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Link, graphql, PageProps } from "gatsby";
import Bio from "@Components/Bio";
import { Layout } from "@Components/Layout/Layout";
import { Seo } from "@Components/Seo/Seo";
import { container, date } from "./BlogPost.module.css";
import { container, date, last_updated } from "./BlogPost.module.css";
import { BlogPostBySlugQuery } from "../../graphql-types";

const BlogPostTemplate: React.FC<PageProps<BlogPostBySlugQuery>> = ({
Expand Down Expand Up @@ -39,8 +39,13 @@ const BlogPostTemplate: React.FC<PageProps<BlogPostBySlugQuery>> = ({
/>
<article itemScope itemType="http://schema.org/Article">
<header>
<h1 itemProp="headline">{post.frontmatter.title}</h1>
<p className={date}>{post.frontmatter.date}</p>
<h1 itemProp="headline">{post.frontmatter.title}</h1>
{post.frontmatter.last_modified && (
<div className={last_updated}>
This post was updated on {post.frontmatter.last_modified}
</div>
)}
<p className={date}>Published on {post.frontmatter.date}</p>
</header>
<section
dangerouslySetInnerHTML={{ __html: post.html }}
Expand Down Expand Up @@ -104,6 +109,7 @@ export const pageQuery = graphql`
frontmatter {
title
date(formatString: "MMMM DD, YYYY")
last_modified(formatString: "MMMM DD, YYYY")
description
}
}
Expand Down