Skip to content

Commit 9ffbbe9

Browse files
authored
repo sync
2 parents 8c9bd73 + bbd9f03 commit 9ffbbe9

File tree

43 files changed

+292
-320
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+292
-320
lines changed

content/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,10 @@ featuredLinks:
184184

185185
### `changelog`
186186

187-
- Purpose: Render a list of changelog items with timestamps on product pages (ex: `layouts/product-landing.html`)
188-
- Type: `Array`, items are objects `{ href: string, title: string, date: 'YYYY-MM-DD' }`
187+
- Purpose: Render a list of items pulled from [GitHub Changelog](https://github.blog/changelog/) on product landing pages (ex: `layouts/product-landing.html`). The one exception is Education, which pulls from https://github.blog/category/community/education.
188+
- Type: `Object`, properties:
189+
- `label` -- must be present and corresponds to the labels used in the [GitHub Changelog](https://github.blog/changelog/)
190+
- `prefix` -- optional string that starts each changelog title that should be omitted in the docs feed. For example, with the prefix `GitHub Actions: ` specified, changelog titles like `GitHub Actions: Some Title Here` will render as `Some Title Here` in the docs feed).
189191
- Optional.
190192

191193
### `defaultPlatform`
@@ -223,7 +225,7 @@ includeGuides:
223225
```
224226

225227
### `type`
226-
- Purpose: Indicate the type of article.
228+
- Purpose: Indicate the type of article.
227229
- Type: `String`, one of the `overview`, `quick_start`, `tutorial`, `how_to`, `reference`.
228230
- Optional.
229231

content/actions/index.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,9 @@ featuredLinks:
2222
- /actions/reference/environment-variables
2323
- /actions/reference/encrypted-secrets
2424
changelog:
25-
- title: Environments, environment protection rules and environment secrets (beta)
26-
date: '2020-12-15'
27-
href: https://github.blog/changelog/2020-12-15-github-actions-environments-environment-protection-rules-and-environment-secrets-beta/
28-
- title: Workflow visualization
29-
date: '2020-12-08'
30-
href: https://github.blog/changelog/2020-12-08-github-actions-workflow-visualization/
31-
- title: Removing set-env and add-path commands on November 16
32-
date: '2020-11-09'
33-
href: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
34-
25+
label: 'actions'
26+
prefix: 'GitHub Actions: '
3527
product_video: https://www.youtube-nocookie.com/embed/cP0I9w2coGU
36-
3728
redirect_from:
3829
- /articles/automating-your-workflow-with-github-actions/
3930
- /articles/customizing-your-project-with-github-actions/

content/discussions/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ featuredLinks:
2222
- /discussions/guides/finding-discussions-across-multiple-repositories
2323
- /discussions/collaborating-with-your-community-using-discussions/collaborating-with-maintainers-using-discussions
2424
- /discussions/managing-discussions-for-your-community/managing-categories-for-discussions-in-your-repository
25+
changelog:
26+
label: 'discussions'
2527
product_video: https://www.youtube-nocookie.com/embed/IpBw2SJkFyk
2628
layout: product-landing
2729
versions:

content/education/index.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,8 @@ featuredLinks:
1919
- /desktop
2020
- /github/getting-started-with-github/github-cli
2121
- /education/manage-coursework-with-github-classroom/teach-with-github-classroom
22-
2322
changelog:
24-
- title: 'Try something new at Local Hack Day: Learn'
25-
date: '2020-10-15'
26-
href: https://github.blog/2020-10-15-try-something-new-at-local-hack-day-learn/
27-
- title: 'Remote Education: Creating community through shared experiences'
28-
date: '2020-09-24'
29-
href: https://github.blog/2020-09-24-remote-education-creating-community-through-shared-experiences/
30-
- title: 'Remote Education: A series of best practices for online campus communities'
31-
date: '2020-09-10'
32-
href: https://github.blog/2020-09-10-remote-education-a-series-of-best-practices-for-online-campus-communities/
33-
- title: Welcome to the inaugural class of MLH Fellows
34-
date: '2020-06-24'
35-
href: https://github.blog/2020-06-24-welcome-to-the-inaugural-class-of-mlh-fellows/
36-
23+
label: 'education'
3724
layout: product-landing
3825
versions:
3926
free-pro-team: '*'

content/packages/index.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,8 @@ featuredLinks:
2020
- /packages/guides/enabling-improved-container-support
2121
- /packages/guides/configuring-rubygems-for-use-with-github-packages
2222
changelog:
23-
- title: ghcr.io maintenance mode on 2021-01-09
24-
date: '2021-01-08'
25-
href: https://github.blog/changelog/2021-01-08-packages-ghcr-io-maintenance-mode-on-2021-01-09/
26-
- title: ghcr.io container names redirect to the container page
27-
date: '2020-12-14'
28-
href: https://github.blog/changelog/2020-12-14-ghcr-io-container-names-redirect-to-the-container-page/
29-
- title: Filter for tagged and untagged containers
30-
date: '2020-12-14'
31-
href: https://github.blog/changelog/2020-12-14-packages-can-filter-for-tagged-and-untagged-containers/
23+
label: 'packages'
24+
prefix: 'Packages: '
3225
redirect_from:
3326
- /github/managing-packages-with-github-packages
3427
- /categories/managing-packages-with-github-package-registry

layouts/product-landing.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ <h2 class="link-with-intro-title f5">{{ link.title }}<span class="Bump-link-symb
9898
<div class="col-12 col-lg-4 mb-4 mb-lg-0">
9999
<div class="featured-links-heading mb-4 d-flex flex-items-baseline">
100100
<h3 class="f4 text-normal text-mono text-uppercase color-gray-5">{% data ui.toc.whats_new %}</h3>
101-
<a href="https://github.blog/changelog/" class="ml-4">View all {% octicon "arrow-right" height="14" class="v-align-middle" %}</a>
101+
<a href="{{ changelogUrl }}" class="ml-4">View all {% octicon "arrow-right" height="14" class="v-align-middle" %}</a>
102102
</div>
103103
<ul class="list-style-none">
104-
{% for link in page.changelog %}
104+
{% for link in whatsNewChangelog %}
105105
<li class="border-top">
106-
<a href="{{ link.href }}" class="d-block text-gray-dark Bump-link--hover py-3 no-underline">
106+
<a href="{{ link.href }}" class="d-block text-gray-dark Bump-link--hover py-3 no-underline capitalize">
107107
<h4>{{ link.title }} <span class="Bump-link-symbol"></span></h4>
108108
<time
109109
class="tooltipped tooltipped-n text-gray-light text-mono mt-1"

lib/changelog.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const Parser = require('rss-parser')
2+
3+
async function getRssFeed (url) {
4+
const parser = new Parser({ timeout: 5000 })
5+
const feedUrl = `${url}/feed`
6+
let feed
7+
8+
try {
9+
feed = await parser.parseURL(feedUrl)
10+
} catch (err) {
11+
console.error(`cannot get ${feedUrl}: ${err.message}`)
12+
return
13+
}
14+
15+
return feed
16+
}
17+
18+
async function getChangelogItems (prefix, feed) {
19+
if (!feed || !feed.items) {
20+
console.log(feed)
21+
console.error('feed is not valid or has no items')
22+
return
23+
}
24+
25+
// only show the first 3 posts
26+
const changelog = feed.items
27+
.slice(0, 3)
28+
.map(item => {
29+
// remove the prefix if it exists (Ex: 'GitHub Actions: '), where the colon and expected whitespace should be hardcoded.
30+
const title = prefix ? item.title.replace(new RegExp(`^${prefix}`), '') : item.title
31+
return {
32+
// capitalize the first letter of the title
33+
title: title.trim().charAt(0).toUpperCase() + title.slice(1),
34+
date: item.isoDate,
35+
href: item.guid
36+
}
37+
})
38+
39+
return changelog
40+
}
41+
42+
module.exports = { getRssFeed, getChangelogItems }

lib/frontmatter.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,10 @@ const schema = {
8080
},
8181
// Shown in `product-landing.html` "What's new" section
8282
changelog: {
83-
type: 'array',
84-
items: {
85-
type: 'object',
86-
properties: {
87-
title: { type: 'string' },
88-
date: { type: 'string', format: 'date' },
89-
href: { type: 'string' }
90-
}
83+
type: 'object',
84+
properties: {
85+
label: { type: 'string' },
86+
prefix: { type: 'string' }
9187
}
9288
},
9389
type: {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const { getRssFeed, getChangelogItems } = require('../../lib/changelog')
2+
3+
module.exports = async function whatsNewChangelog (req, res, next) {
4+
if (!req.context.page) return next()
5+
if (!req.context.page.changelog) return next()
6+
req.context.changelogUrl = req.context.page.changelog.label === 'education'
7+
? 'https://github.blog/category/community/education'
8+
: `https://github.blog/changelog/label/${req.context.page.changelog.label}`
9+
10+
const feed = await getRssFeed(req.context.changelogUrl)
11+
req.context.whatsNewChangelog = await getChangelogItems(req.context.page.changelog.prefix, feed)
12+
return next()
13+
}

middleware/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ module.exports = function (app) {
109109
app.use(instrument('./contextualizers/graphql'))
110110
app.use(instrument('./contextualizers/rest'))
111111
app.use(instrument('./contextualizers/webhooks'))
112+
app.use(asyncMiddleware(instrument('./contextualizers/whats-new-changelog')))
112113
app.use(asyncMiddleware(instrument('./breadcrumbs')))
113114
app.use(asyncMiddleware(instrument('./early-access-breadcrumbs')))
114115
app.use(asyncMiddleware(instrument('./enterprise-server-releases')))

0 commit comments

Comments
 (0)