Skip to content

Commit 8b32634

Browse files
authored
Merge branch 'github:main' into main
2 parents 7e5471a + 96fb518 commit 8b32634

151 files changed

Lines changed: 1985 additions & 1481 deletions

File tree

Some content is hidden

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

.devcontainer/devcontainer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@
2121
"davidanson.vscode-markdownlint",
2222
"bierner.markdown-preview-github-styles",
2323
"yzhang.markdown-all-in-one",
24-
"streetsidesoftware.code-spell-checker"
24+
"streetsidesoftware.code-spell-checker",
25+
"hubwriter.open-reusable"
2526
],
2627

2728
// Use 'forwardPorts' to make a list of ports inside the container available locally.
2829
"forwardPorts": [4000],
2930

3031
// Use 'postCreateCommand' to run commands after the container is created.
31-
"postCreateCommand": "npm ci && npm run build",
32-
32+
"postCreateCommand": "npm ci && npm run build",
33+
3334
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
3435
"remoteUser": "node"
3536
}

.github/actions-scripts/fr-add-docs-reviewers-requests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ async function run() {
120120
const featureID = findFieldID('Feature', data)
121121
const contributorTypeID = findFieldID('Contributor type', data)
122122
const sizeTypeID = findFieldID('Size', data)
123-
const authorID = findFieldID('Author', data)
123+
const authorID = findFieldID('Contributor', data)
124124

125125
// Get the ID of the single select values that we want to set
126126
const readyForReviewID = findSingleSelectID('Ready for review', 'Status', data)

.github/actions-scripts/ready-for-docs-review.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async function run() {
6060
const featureID = findFieldID('Feature', data)
6161
const contributorTypeID = findFieldID('Contributor type', data)
6262
const sizeTypeID = findFieldID('Size', data)
63-
const authorID = findFieldID('Author', data)
63+
const authorID = findFieldID('Contributor', data)
6464

6565
// Get the ID of the single select values that we want to set
6666
const readyForReviewID = findSingleSelectID('Ready for review', 'Status', data)

.vscode/open-reusable-1.3.0.vsix

236 KB
Binary file not shown.

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
"files.exclude": {
33
"**/translations": true
44
}
5-
}
5+
"workbench.editor.enablePreview": false,
6+
"workbench.editor.enablePreviewFromQuickOpen": false
7+
}
70.5 KB
Loading
22.6 KB
Loading

components/article/ArticlePage.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@ const interactiveAlternatives: Record<string, { href: string }> = {
2424
'/actions/automating-builds-and-tests/building-and-testing-python': {
2525
href: '/actions/automating-builds-and-tests/building-and-testing-nodejs-or-python?langId=python',
2626
},
27+
'/codespaces/setting-up-your-project-for-codespaces/setting-up-your-nodejs-project-for-codespaces':
28+
{
29+
href: '/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces?langId=nodejs',
30+
},
31+
'/codespaces/setting-up-your-project-for-codespaces/setting-up-your-dotnet-project-for-codespaces':
32+
{
33+
href: '/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces?langId=dotnet',
34+
},
35+
'/codespaces/setting-up-your-project-for-codespaces/setting-up-your-java-project-for-codespaces':
36+
{
37+
href: '/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces?langId=java',
38+
},
39+
'/codespaces/setting-up-your-project-for-codespaces/setting-up-your-python-project-for-codespaces':
40+
{
41+
href: '/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces?langId=py',
42+
},
2743
}
2844

2945
export const ArticlePage = () => {

components/context/PlaygroundContext.tsx

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@ import React, { createContext, useContext, useState } from 'react'
22
import { CodeLanguage, PlaygroundArticleT } from 'components/playground/types'
33
import { useRouter } from 'next/router'
44

5-
import jsArticle from 'components/playground/content/building-and-testing/nodejs'
6-
import pyArticle from 'components/playground/content/building-and-testing/python'
5+
import actionsJsArticle from 'components/playground/content/actions/guides/building-and-testing-nodejs-or-python/nodejs'
6+
import actionsPyArticle from 'components/playground/content/actions/guides/building-and-testing-nodejs-or-python/python'
7+
import codespacesJsArticle from 'components/playground/content/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces/nodejs'
8+
import codespacesPyArticle from 'components/playground/content/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces/python'
9+
import codespacesNetArticle from 'components/playground/content/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces/dotnet'
10+
import codespacesJavaArticle from 'components/playground/content/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces/java'
711

8-
const articles = [jsArticle, pyArticle]
9-
const articlesByLangId = articles.reduce((obj, item) => {
10-
obj[item.codeLanguageId] = item
11-
return obj
12-
}, {} as Record<string, PlaygroundArticleT | undefined>)
12+
const articles = [
13+
actionsJsArticle,
14+
actionsPyArticle,
15+
codespacesJsArticle,
16+
codespacesPyArticle,
17+
codespacesJavaArticle,
18+
codespacesNetArticle,
19+
]
1320

1421
const codeLanguages: Array<CodeLanguage> = [
1522
{
@@ -20,6 +27,14 @@ const codeLanguages: Array<CodeLanguage> = [
2027
id: 'py',
2128
label: 'Python',
2229
},
30+
{
31+
id: 'dotnet',
32+
label: 'C#',
33+
},
34+
{
35+
id: 'java',
36+
label: 'Java',
37+
},
2338
]
2439

2540
type PlaygroundContextT = {
@@ -48,19 +63,26 @@ export const PlaygroundContextProvider = (props: { children: React.ReactNode })
4863
const router = useRouter()
4964
const [activeSectionIndex, setActiveSectionIndex] = useState(0)
5065
const [scrollToSection, setScrollToSection] = useState<number>()
66+
const path = router.asPath.split('?')[0]
67+
const relevantArticles = articles.filter(({ slug }) => slug === path)
68+
5169
const { langId } = router.query
52-
const currentLanguage = codeLanguages.find(({ id }) => id === langId) || codeLanguages[0]
53-
const availableLanguages = codeLanguages.filter(({ id }) => !!articlesByLangId[id])
70+
const availableLanguageIds = relevantArticles.map(({ codeLanguageId }) => codeLanguageId)
71+
const currentLanguage =
72+
codeLanguages.find(({ id }) => id === langId) ||
73+
(codeLanguages.find(({ id }) => id === availableLanguageIds[0]) as CodeLanguage)
5474

55-
const article = articlesByLangId[currentLanguage.id]
75+
const article = relevantArticles.find(
76+
({ codeLanguageId }) => codeLanguageId === currentLanguage?.id
77+
)
5678

5779
const context = {
5880
activeSectionIndex,
5981
setActiveSectionIndex,
6082
scrollToSection,
6183
setScrollToSection,
6284
currentLanguage,
63-
codeLanguages: availableLanguages,
85+
codeLanguages: codeLanguages.filter(({ id }) => availableLanguageIds.includes(id)),
6486
article,
6587
}
6688

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import { GetServerSideProps } from 'next'
2+
import { BeakerIcon, ZapIcon } from '@primer/octicons-react'
3+
4+
import { MainContextT, MainContext, getMainContext } from 'components/context/MainContext'
5+
6+
import {
7+
PlaygroundContextProvider,
8+
usePlaygroundContext,
9+
} from 'components/context/PlaygroundContext'
10+
import { PlaygroundArticle } from 'components/playground/PlaygroundArticle'
11+
12+
import { Editor } from 'components/playground/editor/Editor'
13+
import { DefaultLayout } from 'components/DefaultLayout'
14+
import { CodeLanguagePicker } from 'components/playground/CodeLanguagePicker'
15+
import { Link } from 'components/Link'
16+
import { useRouter } from 'next/router'
17+
import { Callout } from 'components/ui/Callout'
18+
import { GenericError } from 'components/GenericError'
19+
20+
type Props = {
21+
mainContext: MainContextT
22+
}
23+
export default function PlaygroundArticlePage({ mainContext }: Props) {
24+
return (
25+
<MainContext.Provider value={mainContext}>
26+
<DefaultLayout>
27+
<PlaygroundContextProvider>
28+
<PageInner />
29+
</PlaygroundContextProvider>
30+
</DefaultLayout>
31+
</MainContext.Provider>
32+
)
33+
}
34+
35+
function PageInner() {
36+
const router = useRouter()
37+
const { article } = usePlaygroundContext()
38+
39+
if (!article) {
40+
return <GenericError />
41+
}
42+
43+
return (
44+
<div className="p-responsive my-5 mx-auto" style={{ maxWidth: 1600, minWidth: 768 }}>
45+
<div className="d-flex">
46+
<article className="col-6 ml-lg-3 mr-3">
47+
<Callout variant="info">
48+
<p className="d-flex">
49+
<span className="mr-3 mt-1">
50+
<BeakerIcon size={18} />
51+
</span>
52+
<span>
53+
You've found one of our experimental articles! Have ideas or feedback for how we can
54+
further improve this article? Let us know{' '}
55+
<Link href="https://github.com/github/docs/discussions/9369" target="_blank">
56+
in the discussion
57+
</Link>
58+
.
59+
</span>
60+
</p>
61+
</Callout>
62+
<PlaygroundArticle />
63+
</article>
64+
65+
<div className="col-6">
66+
<div className="fix position-sticky mt-3" style={{ top: '6.5em' }}>
67+
<div className="d-flex flex-justify-between flex-items-center mb-3">
68+
<CodeLanguagePicker variant="tabs" />
69+
<div className="flash">
70+
<ZapIcon className="mr-2" />
71+
<Link href={`/${router.locale}${article.originalArticle}`}>
72+
Switch to non-interactive article
73+
</Link>
74+
</div>
75+
</div>
76+
77+
<Editor article={article} />
78+
</div>
79+
</div>
80+
</div>
81+
</div>
82+
)
83+
}
84+
85+
export const getServerSideProps: GetServerSideProps<Props> = async (context) => {
86+
const req = context.req as any
87+
const res = context.res as any
88+
89+
return {
90+
props: {
91+
mainContext: getMainContext(req, res),
92+
},
93+
}
94+
}

0 commit comments

Comments
 (0)