Adding effectiveDate frontmatter property (#22317)
* adding effectiveDate frontmatter property * Update components/article/ArticlePage.tsx Co-authored-by: Peter Bengtsson <peterbe@github.com> * adding validation for correct date * update to dateTime * update to year month day * update error date validation * moving validation to getArticleContextFromRequest and moving id to div * remove enteredDate * Update content/README.md Co-authored-by: Laura Coursen <lecoursen@github.com> Co-authored-by: Peter Bengtsson <peterbe@github.com> Co-authored-by: Laura Coursen <lecoursen@github.com>
This commit is contained in:
@@ -32,6 +32,7 @@ export const ArticlePage = () => {
|
||||
const {
|
||||
title,
|
||||
intro,
|
||||
effectiveDate,
|
||||
renderedPage,
|
||||
contributor,
|
||||
permissions,
|
||||
@@ -153,6 +154,14 @@ export const ArticlePage = () => {
|
||||
>
|
||||
<div id="article-contents">
|
||||
<MarkdownContent>{renderedPage}</MarkdownContent>
|
||||
{effectiveDate && (
|
||||
<div className="mt-4" id="effectiveDate">
|
||||
Effective as of:{' '}
|
||||
<time dateTime={new Date(effectiveDate).toISOString()}>
|
||||
{new Date(effectiveDate).toDateString()}
|
||||
</time>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ArticleGridLayout>
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ export type MiniTocItem = {
|
||||
export type ArticleContextT = {
|
||||
title: string
|
||||
intro: string
|
||||
effectiveDate: string
|
||||
renderedPage: string
|
||||
miniTocItems: Array<MiniTocItem>
|
||||
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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -6,6 +6,7 @@ redirect_from:
|
||||
- /github/copilot/telemetry-terms
|
||||
versions:
|
||||
fpt: '*'
|
||||
effectiveDate: '2021-10-04'
|
||||
---
|
||||
|
||||
## Additional telemetry
|
||||
|
||||
@@ -92,6 +92,9 @@ export const schema = {
|
||||
examples_source: {
|
||||
type: 'string',
|
||||
},
|
||||
effectiveDate: {
|
||||
type: 'string',
|
||||
},
|
||||
featuredLinks: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user