Skip to content

Commit 7618fea

Browse files
authored
Merge branch 'main' into domain-verification-enterprise-account-beta-redux
2 parents 522988e + a7466b6 commit 7618fea

18 files changed

Lines changed: 3265 additions & 634 deletions

File tree

.github/workflows/close-unwanted-pull-requests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
- 'lib/webhooks/**'
1313
jobs:
1414
close_unwanted_pull_requests:
15-
if: github.repository == 'github/docs'
15+
if: github.repository == 'github/docs' && github.event.pull_request.user.login != 'Octomerger'
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9

content/actions/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ changelog:
3737
- title: Self-Hosted Runner Group Access Changes
3838
date: '2020-10-16'
3939
href: https://github.blog/changelog/2020-10-16-github-actions-self-hosted-runner-group-access-changes/
40+
41+
product_video: https://www.youtube-nocookie.com/embed/cP0I9w2coGU
4042

4143
redirect_from:
4244
- /articles/automating-your-workflow-with-github-actions/

content/developers/overview/about-githubs-apis.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ versions:
99
github-ae: '*'
1010
---
1111

12-
There are two stable versions of the GitHub API: the [REST API](/rest) and the [GraphQL API](/graphql).
13-
14-
When using the REST API, we encourage you to [request v3 via the `Accept` header](/rest/overview/media-types#request-specific-version).
15-
16-
For information on using the GraphQL API, see the [v4 docs](/graphql).
12+
There are two stable versions of the GitHub API: the [REST API](/rest) and the [GraphQL API](/graphql). When using the REST API, we encourage you to [request v3 via the `Accept` header](/v3/media/#request-specific-version). For information on using the GraphQL API, see the [v4 docs](/graphql).
1713

1814
## Deprecated versions
1915

includes/small-footer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<ul class="d-flex list-style-none flex-wrap flex-justify-center flex-xl-justify-start">
44
<li class="d-flex mr-xl-3 text-gray">
55
{% octicon "mark-github" height="20" class="mr-2 mr-xl-3" %}
6-
<span>{{ "now" | date: "%Y" }} GitHub, Inc.</span>
6+
<span>&copy; {{ "now" | date: "%Y" }} GitHub, Inc.</span>
77
</li>
88
<li class="ml-3"><a href="/github/site-policy/github-terms-of-service">{% data ui.footer.terms %} </a></li>
99
<li class="ml-3"><a href="/github/site-policy/github-privacy-statement">{% data ui.footer.privacy %} </a></li>

layouts/product-landing.html

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
{% include header %}
1010

1111
<div class="container-xl px-3 px-md-6 pt-3 pb-2">
12-
<header class="d-flex gutter mb-6">
13-
<div class="col-12 col-lg-7">
12+
<header class="d-lg-flex gutter-lg mb-6">
13+
<div class="col-12 col-lg-6 mb-2 mb-lg-0">
1414
<span class="text-mono text-gray">Product</span>
1515
<h1 class="mb-3 font-mktg">{{ page.shortTitle }}</h1>
1616
<div class="lead-mktg text-gray">{{ page.intro }}</div>
@@ -23,6 +23,19 @@ <h1 class="mb-3 font-mktg">{{ page.shortTitle }}</h1>
2323
{% data ui.product_landing.reference_guides %}
2424
</a>
2525
</div>
26+
27+
{% if page.product_video %}
28+
<div class="col-12 col-lg-6">
29+
<div class="position-relative" style="padding-bottom:56.25%;">
30+
<iframe
31+
class="top-0 left-0 position-absolute box-shadow-large rounded-1 width-full height-full"
32+
src="{{ page.product_video }}"
33+
frameborder="0"
34+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen
35+
></iframe>
36+
</div>
37+
</div>
38+
{% endif %}
2639
</header>
2740

2841
<!-- Article links -->

lib/frontmatter.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ const schema = {
8787
href: { type: 'string' }
8888
}
8989
}
90+
},
91+
// Show in `product-landing.html`
92+
product_video: {
93+
type: 'string',
94+
format: 'url'
95+
},
96+
interactive: {
97+
type: 'boolean'
9098
}
9199
}
92100
}

lib/page.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const pathUtils = require('./path-utils')
1616
const Permalink = require('./permalink')
1717
const languages = require('./languages')
1818
const renderContent = require('./render-content')
19+
const { renderReact } = require('./react/engine')
1920
const frontmatter = require('./frontmatter')
2021
const products = require('./all-products')
2122
const slash = require('slash')
@@ -133,10 +134,31 @@ class Page {
133134
this.title = await renderContent(this.rawTitle, context, { textOnly: true, encodeEntities: true })
134135
this.shortTitle = await renderContent(this.shortTitle, context, { textOnly: true, encodeEntities: true })
135136

136-
const markdown = this.mapTopic
137+
let markdown = this.mapTopic
137138
? getMapTopicContent(this, context.pages, context.redirects)
138139
: this.markdown
139140

141+
// If the article is interactive parse the React!
142+
if (this.interactive) {
143+
// Search for the react code comments to find the react components
144+
const reactComponents = markdown.match(/<!--react-->(.*?)<!--end-react-->/gs)
145+
146+
// Render each of the react components in the markdown
147+
await Promise.all(reactComponents.map(async (reactComponent) => {
148+
let componentStr = reactComponent
149+
150+
// Remove the React comment indicators
151+
componentStr = componentStr.replace('<!--react-->\n', '').replace('<!--react-->', '')
152+
componentStr = componentStr.replace('\n<!--end-react-->', '').replace('<!--end-react-->', '')
153+
154+
// Get the rendered component
155+
const renderedComponent = await renderReact(componentStr)
156+
157+
// Replace the react component with the rendered markdown
158+
markdown = markdown.replace(reactComponent, renderedComponent)
159+
}))
160+
}
161+
140162
const html = await renderContent(markdown, context)
141163

142164
// product frontmatter may contain liquid

lib/react/babel.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const babel = require('@babel/core')
2+
3+
const reactBabelOptions = {
4+
presets: [
5+
'@babel/preset-env',
6+
'@babel/preset-react'
7+
],
8+
plugins: [
9+
'@babel/plugin-transform-react-jsx',
10+
'@babel/plugin-proposal-object-rest-spread',
11+
'@babel/plugin-proposal-class-properties',
12+
'@babel/transform-runtime'
13+
]
14+
}
15+
16+
const transform = code =>
17+
babel.transform(code, reactBabelOptions).code
18+
19+
module.exports = {
20+
transform: transform,
21+
reactBabelOptions: reactBabelOptions
22+
}

lib/react/engine.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
const { renderToString } = require('react-dom/server')
2+
const { transform } = require('./babel')
3+
const React = require('react')
4+
const fs = require('fs')
5+
const path = require('path')
6+
const dirTree = require('directory-tree')
7+
8+
// Name of directory for saving transformed components that should be gitignored
9+
const dist = 'dist'
10+
11+
// Build React components
12+
// This loops through the react components and transpiles them to /dist
13+
// so they can be used by Node.js when we do server side rendering
14+
const tree = dirTree('./react/')
15+
if (tree) {
16+
for (const index in tree.children) {
17+
const file = tree.children[index]
18+
if (file.type === 'file' && file.extension === '.js') {
19+
if (!fs.existsSync(path.join(dist, 'react'))) {
20+
fs.mkdirSync(path.join(dist, 'react'), { recursive: true })
21+
}
22+
const content = transform(fs.readFileSync(file.path, 'utf8'))
23+
fs.writeFileSync(path.join(dist, file.path), content)
24+
}
25+
}
26+
}
27+
// End Build React Components
28+
29+
// Register components
30+
const components = {
31+
// CodeBlock: require('../../dist/react/CodeBlock'),
32+
// CodeEditor: require('../../dist/react/CodeEditor')
33+
}
34+
35+
const renderReact = async componentStr => {
36+
// Get component name as string so we can use it in the class name
37+
// which will be needed later if we choose to do client side React hydration
38+
const componentName = componentStr.match(/<([a-zA-Z]+)\s/)[1]
39+
// Add the wrapper and class name so we can later use React hydration on the client
40+
// side
41+
const jsx = `<div className="react-component-${componentName}">\n${componentStr}\n</div>`
42+
43+
const component = transform(jsx)
44+
45+
// eslint-disable-next-line
46+
const getComponent = new Function(
47+
'React',
48+
...Object.keys(components),
49+
`${component.replace('React', 'return React')}`
50+
)
51+
52+
return renderToString(getComponent(React, ...Object.values(components)))
53+
}
54+
55+
module.exports = {
56+
renderReact
57+
}

middleware/csp.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ module.exports = contentSecurityPolicy({
3434
],
3535
frameSrc: [ // exceptions for GraphQL Explorer
3636
'https://graphql-explorer.githubapp.com', // production env
37-
'http://localhost:3000' // development env
37+
'http://localhost:3000', // development env
38+
'https://www.youtube-nocookie.com'
3839
],
3940
styleSrc: [
4041
"'self'",

0 commit comments

Comments
 (0)