diff --git a/content/blog/how-to-build-feature-flags-react/index.md b/content/blog/how-to-build-feature-flags-react/index.md index 3b8daff5..49720099 100644 --- a/content/blog/how-to-build-feature-flags-react/index.md +++ b/content/blog/how-to-build-feature-flags-react/index.md @@ -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 --- diff --git a/gatsby-config.ts b/gatsby-config.ts index 245eb475..99d45be9 100644 --- a/gatsby-config.ts +++ b/gatsby-config.ts @@ -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(), }; }, }, diff --git a/graphql-types.ts b/graphql-types.ts index 56d8d348..6b789e80 100644 --- a/graphql-types.ts +++ b/graphql-types.ts @@ -247,6 +247,8 @@ export type DirectoryCtimeArgs = { export type Site = Node & { buildTime?: Maybe; siteMetadata?: Maybe; + port?: Maybe; + host?: Maybe; polyfill?: Maybe; pathPrefix?: Maybe; jsxRuntime?: Maybe; @@ -694,6 +696,7 @@ export type Frontmatter = { featured_image?: Maybe; order?: Maybe; link?: Maybe; + last_modified?: Maybe; }; @@ -720,6 +723,14 @@ export type FrontmatterTo_DateArgs = { locale?: InputMaybe; }; + +export type FrontmatterLast_ModifiedArgs = { + formatString?: InputMaybe; + fromNow?: InputMaybe; + difference?: InputMaybe; + locale?: InputMaybe; +}; + export type Fields = { slug?: Maybe; }; @@ -850,6 +861,8 @@ export type QueryAllDirectoryArgs = { export type QuerySiteArgs = { buildTime?: InputMaybe; siteMetadata?: InputMaybe; + port?: InputMaybe; + host?: InputMaybe; polyfill?: InputMaybe; pathPrefix?: InputMaybe; jsxRuntime?: InputMaybe; @@ -1084,6 +1097,7 @@ export type FrontmatterFilterInput = { featured_image?: InputMaybe; order?: InputMaybe; link?: InputMaybe; + last_modified?: InputMaybe; }; export type FileFilterInput = { @@ -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' @@ -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' @@ -2143,6 +2159,8 @@ export type SiteFieldsEnum = | 'siteMetadata___author___summary' | 'siteMetadata___siteUrl' | 'siteMetadata___social___twitter' + | 'port' + | 'host' | 'polyfill' | 'pathPrefix' | 'jsxRuntime' @@ -2278,6 +2296,8 @@ export type SiteGroupConnectionGroupArgs = { export type SiteFilterInput = { buildTime?: InputMaybe; siteMetadata?: InputMaybe; + port?: InputMaybe; + host?: InputMaybe; polyfill?: InputMaybe; pathPrefix?: InputMaybe; jsxRuntime?: InputMaybe; @@ -3268,6 +3288,7 @@ export type MarkdownRemarkFieldsEnum = | 'frontmatter___featured_image___internal___type' | 'frontmatter___order' | 'frontmatter___link' + | 'frontmatter___last_modified' | 'fields___slug' | 'excerpt' | 'rawMarkdownBody' @@ -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 }; diff --git a/src/templates/BlogPost.module.css b/src/templates/BlogPost.module.css index 6621a80b..3a6e9785 100644 --- a/src/templates/BlogPost.module.css +++ b/src/templates/BlogPost.module.css @@ -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); diff --git a/src/templates/BlogPost.tsx b/src/templates/BlogPost.tsx index 2c2000ac..01ff7f8a 100644 --- a/src/templates/BlogPost.tsx +++ b/src/templates/BlogPost.tsx @@ -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> = ({ @@ -39,8 +39,13 @@ const BlogPostTemplate: React.FC> = ({ />
-

{post.frontmatter.title}

-

{post.frontmatter.date}

+

{post.frontmatter.title}

+ {post.frontmatter.last_modified && ( +
+ This post was updated on {post.frontmatter.last_modified} +
+ )} +

Published on {post.frontmatter.date}