diff --git a/components/article/ArticlePage.tsx b/components/article/ArticlePage.tsx index 888219eec00d..fb15bbabb9f5 100644 --- a/components/article/ArticlePage.tsx +++ b/components/article/ArticlePage.tsx @@ -32,6 +32,7 @@ export const ArticlePage = () => { const { title, intro, + effectiveDate, renderedPage, contributor, permissions, @@ -153,6 +154,14 @@ export const ArticlePage = () => { >
{renderedPage} + {effectiveDate && ( +
+ Effective as of:{' '} + +
+ )}
diff --git a/components/context/ArticleContext.tsx b/components/context/ArticleContext.tsx index b6e09e7beae6..c6ced603aeb7 100644 --- a/components/context/ArticleContext.tsx +++ b/components/context/ArticleContext.tsx @@ -16,6 +16,7 @@ export type MiniTocItem = { export type ArticleContextT = { title: string intro: string + effectiveDate: string renderedPage: string miniTocItems: Array contributor: { name: string; URL: string } | null @@ -40,9 +41,19 @@ export const useArticleContext = (): ArticleContextT => { export const getArticleContextFromRequest = (req: any): ArticleContextT => { const page = req.context.page + + if (page.effectiveDate) { + if (isNaN(Date.parse(page.effectiveDate))) { + throw new Error( + 'The "effectiveDate" frontmatter property is not valid. Please make sure it is YEAR-MONTH-DAY' + ) + } + } + return { title: page.titlePlainText, intro: page.intro, + effectiveDate: page.effectiveDate || '', renderedPage: req.context.renderedPage || '', miniTocItems: req.context.miniTocItems || [], contributor: page.contributor || null, diff --git a/content/README.md b/content/README.md index 8a56ce0ab5e2..6f21aef351c3 100644 --- a/content/README.md +++ b/content/README.md @@ -29,6 +29,7 @@ See the [contributing docs](/CONTRIBUTING.md) for general information about work - [`topics`](#topics) - [`contributor`](#contributor) - [`communityRedirect`](#communityRedirect) + - [`effectiveDate`](#effectiveDate) - [Escaping single quotes](#escaping-single-quotes) - [Autogenerated mini TOCs](#autogenerated-mini-tocs) - [Versioning](#versioning) @@ -270,6 +271,11 @@ includeGuides: - Type: `Object`. Properties are `name` and `href`. - Optional. +### `effectiveDate` +- **For GitHub staff only**: Set an effective date for Terms of Service articles so that engineering teams can automatically re-prompt users to confirm the terms +- Type: `string` YEAR-MONTH-DAY e.g. 2021-10-04 is October 4th, 2021 +- Optional. + Example: ```yaml diff --git a/content/github/copilot/github-copilot-telemetry-terms.md b/content/github/copilot/github-copilot-telemetry-terms.md index 940783a62f2c..ef3c3b99c628 100644 --- a/content/github/copilot/github-copilot-telemetry-terms.md +++ b/content/github/copilot/github-copilot-telemetry-terms.md @@ -6,6 +6,7 @@ redirect_from: - /github/copilot/telemetry-terms versions: fpt: '*' +effectiveDate: '2021-10-04' --- ## Additional telemetry diff --git a/lib/frontmatter.js b/lib/frontmatter.js index a364198df2c3..89faf86d1a80 100644 --- a/lib/frontmatter.js +++ b/lib/frontmatter.js @@ -92,6 +92,9 @@ export const schema = { examples_source: { type: 'string', }, + effectiveDate: { + type: 'string', + }, featuredLinks: { type: 'object', properties: { diff --git a/middleware/render-page.js b/middleware/render-page.js index d0882d556af0..1fe891d68c55 100644 --- a/middleware/render-page.js +++ b/middleware/render-page.js @@ -32,6 +32,12 @@ export default async function renderPage(req, res, next) { // add page context const context = Object.assign({}, req.context, { page }) + // Updating the Last-Modified header for substantive changes on a page for engineering + // Docs Engineering Issue #945 + if (context.page.effectiveDate !== '') { + res.setHeader('Last-Modified', new Date(context.page.effectiveDate).toUTCString()) + } + // collect URLs for variants of this page in all languages context.page.languageVariants = Page.getLanguageVariants(req.pagePath) // Stop processing if the connection was already dropped