Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repo sync #32979

Merged
merged 5 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# --------------------------------------------------------------------------------
# To update the sha, run `docker pull node:$VERSION-alpine`
# look for something like: `Digest: sha256:0123456789abcdef`
FROM node:20-alpine@sha256:7a91aa397f2e2dfbfcdad2e2d72599f374e0b0172be1d86eeb73f1d33f36a4b2 as base
FROM node:20-alpine@sha256:291e84d956f1aff38454bbd3da38941461ad569a185c20aa289f71f37ea08e23 as base

# This directory is owned by the node user
ARG APP_HOME=/home/node/app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
### A third-level heading
```

![Screenshot of rendered GitHub Markdown showing sample h1, h2, and h3 headers, which descend in type size and visual weight to indicate descending hierarchy level.](/assets/images/help/writing/headings-rendered.png)

Check warning on line 24 in content/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.md

View workflow job for this annotation

GitHub Actions / lint-content

Images alternate text should be between 40-150 characters

Image alternate text is 162 characters long.

When you use two or more headings, GitHub automatically generates a table of contents that you can access by clicking {% octicon "list-unordered" aria-label="The unordered list icon" %} within the file header. Each heading title is listed in the table of contents and you can click a title to navigate to the selected section.

![Screenshot of the README file in the GitHub Docs open source repository with the drop-down menu for the table of contents exposed. The table of contents icon is outlined in dark orange.](/assets/images/help/repository/headings-toc.png)

Check warning on line 28 in content/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.md

View workflow job for this annotation

GitHub Actions / lint-content

Images alternate text should be between 40-150 characters

Image alternate text is 185 characters long.

## Styling text

Expand Down Expand Up @@ -53,7 +53,7 @@

Quoted text is indented, with a different type color.

![Screenshot of rendered GitHub Markdown showing sample quoted text. The quote is indented with a vertical line on the left, and its text is dark gray rather than black.](/assets/images/help/writing/quoted-text-rendered.png)

Check warning on line 56 in content/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.md

View workflow job for this annotation

GitHub Actions / lint-content

Images alternate text should be between 40-150 characters

Image alternate text is 167 characters long.

{% note %}

Expand All @@ -69,20 +69,20 @@
Use `git status` to list all new or modified files that haven't yet been committed.
```

![Screenshot of rendered GitHub Markdown showing the appearance of characters surrounded by backticks. The words "git status" appear in a fixed-width typeface, highlighted in light gray.](/assets/images/help/writing/inline-code-rendered.png)

Check warning on line 72 in content/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.md

View workflow job for this annotation

GitHub Actions / lint-content

Images alternate text should be between 40-150 characters

Image alternate text is 184 characters long.

To format code or text into its own distinct block, use triple backticks.

<pre>
````text
Some basic Git commands are:
```
git status
git add
git commit
```
</pre>
````

![Screenshot of rendered GitHub Markdown showing a code block. The words "git status," "git add," and "git commit" appear in a fixed-width typeface, highlighted in light gray.](/assets/images/help/writing/code-block-rendered.png)

Check warning on line 85 in content/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.md

View workflow job for this annotation

GitHub Actions / lint-content

Images alternate text should be between 40-150 characters

Image alternate text is 173 characters long.

For more information, see "[AUTOTITLE](/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks)."

Expand All @@ -96,7 +96,7 @@
The background color is `#ffffff` for light mode and `#000000` for dark mode.
```

![Screenshot of rendered GitHub Markdown showing how HEX values within backticks create small circles of color. #ffffff shows a white circle, and #000000 shows a black circle.](/assets/images/help/writing/supported-color-models-rendered.png)

Check warning on line 99 in content/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.md

View workflow job for this annotation

GitHub Actions / lint-content

Images alternate text should be between 40-150 characters

Image alternate text is 173 characters long.

Here are the currently supported color models.

Expand Down Expand Up @@ -225,7 +225,7 @@

![Screenshot of Markdown in {% data variables.product.prodname_vscode %} showing how indented bullets align vertically with the first letter of the text lines above them.](/assets/images/help/writing/nested-list-alignment.png)

![Screenshot of rendered GitHub Markdown showing a numbered item followed by a bulleted item nested one level to the right, and another bulleted item nested yet further to the right.](/assets/images/help/writing/nested-list-example-1.png)

Check warning on line 228 in content/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.md

View workflow job for this annotation

GitHub Actions / lint-content

Images alternate text should be between 40-150 characters

Image alternate text is 180 characters long.

To create a nested list in the comment editor on {% data variables.product.product_name %}, which doesn't use a monospaced font, you can look at the list item immediately above the nested list and count the number of characters that appear before the content of the item. Then type that number of space characters in front of the nested list item.

Expand All @@ -246,12 +246,10 @@
- Second nested list item
```

![Screenshot of rendered GitHub Markdown showing a list item prefaced by the number 100 followed by a bulleted item nested one level to the right, and another bulleted item nested yet further to the right.](/assets/images/help/writing/nested-list-example-2.png)

Check warning on line 249 in content/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.md

View workflow job for this annotation

GitHub Actions / lint-content

Images alternate text should be between 40-150 characters

Image alternate text is 203 characters long.

For more examples, see the [GitHub Flavored Markdown Spec](https://github.github.com/gfm/#example-265).

{% ifversion task-lists-v1 %}

## Task lists

{% data reusables.repositories.task-list-markdown %}
Expand All @@ -261,7 +259,6 @@
`- [ ] \(Optional) Open a followup issue`

For more information, see "[AUTOTITLE](/get-started/writing-on-github/working-with-advanced-formatting/about-task-lists)."
{% endif %}

## Mentioning people and teams

Expand Down Expand Up @@ -386,7 +383,7 @@

`Let's rename \*our-new-project\* to \*our-old-project\*.`

![Screenshot of rendered GitHub Markdown showing how backslashes prevent the conversion of asterisks to italics. The text reads, "Let's rename our-new-project to our-old-project."](/assets/images/help/writing/escaped-character-rendered.png)

Check warning on line 386 in content/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.md

View workflow job for this annotation

GitHub Actions / lint-content

Images alternate text should be between 40-150 characters

Image alternate text is 177 characters long.

For more information on backslashes, see Daring Fireball's "[Markdown Syntax](https://daringfireball.net/projects/markdown/syntax#backslash)."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
- /issues/tracking-your-work-with-issues/creating-issues/about-task-lists
- /issues/tracking-your-work-with-issues/about-task-lists
versions:
feature: task-lists-v1
fpt: '*'
ghes: '*'
ghec: '*'
topics:
- Pull requests
- Issues
Expand Down Expand Up @@ -75,7 +77,7 @@

Any issues that are referenced in a task list specify that they are tracked by the issue that contains the task list. To navigate to the tracking issue from the tracked issue, click on the tracking issue number in the **Tracked in** section next to the issue status.

![Screenshot of a {% data variables.product.prodname_dotcom %} issue named "Create relationships between issues" and numbered issue 3. A button below the issue title reading "Tracked by issue #2" is outlined in dark orange.](/assets/images/help/writing/task-list-tracked.png)

Check warning on line 80 in content/get-started/writing-on-github/working-with-advanced-formatting/about-task-lists.md

View workflow job for this annotation

GitHub Actions / lint-content

Images alternate text should be between 40-150 characters

Image alternate text is 183 characters long.

{% endif %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You can use {% data variables.product.prodname_projects_v2 %} to manage your wor

Breaking a large issue into smaller issues makes the work more manageable and enables team members to work in parallel. It also leads to smaller pull requests, which are easier to review.

To track how smaller issues fit into the larger goal, use {% ifversion task-lists-v1 %}task lists, milestones, or labels.{% else %} milestones or labels.{% endif %} For more information, see {% ifversion projects-v2-tasklists %}"[AUTOTITLE](/issues/tracking-your-work-with-issues/about-tasklists)"{% endif %}{% ifversion ghes %}"[AUTOTITLE](/get-started/writing-on-github/working-with-advanced-formatting/about-task-lists)"{% endif %}, "[AUTOTITLE](/issues/using-labels-and-milestones-to-track-work/about-milestones)", and "[AUTOTITLE](/issues/using-labels-and-milestones-to-track-work/managing-labels)."
To track how smaller issues fit into the larger goal, use task lists, milestones, or labels. For more information, see {% ifversion projects-v2-tasklists %}"[AUTOTITLE](/issues/tracking-your-work-with-issues/about-tasklists)"{% endif %}{% ifversion ghes %}"[AUTOTITLE](/get-started/writing-on-github/working-with-advanced-formatting/about-task-lists)"{% endif %}, "[AUTOTITLE](/issues/using-labels-and-milestones-to-track-work/about-milestones)", and "[AUTOTITLE](/issues/using-labels-and-milestones-to-track-work/managing-labels)."

## Communicate

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,13 @@ Here is an example of an issue created for a large initiative, front-end work, i

![Screenshot of an issue called "Front-end work for Project Octocat." The issue body includes a list of tasks to complete.](/assets/images/help/issues/quickstart-create-large-initiative-issue.png)

{% ifversion task-lists-v1 %}

### Task list example

You can use task lists to break larger issues down into smaller tasks and to track issues as part of a larger goal. {% ifversion fpt or ghec %} Task lists have additional functionality when added to the body of an issue. You can see the number of tasks completed out of the total at the top of the issue, and if someone closes an issue linked in the task list, the checkbox will automatically be marked as complete.{% endif %} For more information, see "[AUTOTITLE](/get-started/writing-on-github/working-with-advanced-formatting/about-task-lists)."

Below we have added a task list to our Project Octocat issue, breaking it down into smaller issues.

![Screenshot of an issue called "Front-end work for Project Octocat." The issue body contains a task list, with a checkbox preceding each issue link.](/assets/images/help/issues/quickstart-add-task-list-to-issue.png)
{% endif %}

## Making decisions as a team

Expand Down Expand Up @@ -147,8 +144,8 @@ You have now learned about the tools {% data variables.product.prodname_dotcom %
- "[AUTOTITLE](/repositories/creating-and-managing-repositories/about-repositories)" for learning more about creating repositories
- "[AUTOTITLE](/issues/tracking-your-work-with-issues)" for learning more about different ways to create and manage issues
- "[AUTOTITLE](/communities/using-templates-to-encourage-useful-issues-and-pull-requests/about-issue-and-pull-request-templates)" for learning more about issue templates
- "[AUTOTITLE](/issues/using-labels-and-milestones-to-track-work/managing-labels)" for learning how to create, edit and delete labels{% ifversion task-lists-v1 %}
- "[AUTOTITLE](/get-started/writing-on-github/working-with-advanced-formatting/about-task-lists)" for learning more about task lists{% endif %}
- "[AUTOTITLE](/issues/using-labels-and-milestones-to-track-work/managing-labels)" for learning how to create, edit and delete labels
- "[AUTOTITLE](/get-started/writing-on-github/working-with-advanced-formatting/about-task-lists)" for learning more about task lists
{% ifversion projects-v2 %} - "[AUTOTITLE](/issues/planning-and-tracking-with-projects/learning-about-projects/about-projects)" for learning more about projects
- "[AUTOTITLE](/issues/planning-and-tracking-with-projects/customizing-views-in-your-project/changing-the-layout-of-a-view)" for learning how to customize views for projects{% endif %}
{% ifversion projects-v1 %}- "[AUTOTITLE](/issues/organizing-your-work-with-project-boards/managing-project-boards/about-project-boards)" for learning how to manage {% data variables.projects.projects_v1_boards %}{% endif %}
3 changes: 0 additions & 3 deletions content/issues/tracking-your-work-with-issues/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,11 @@ You can use markdown to add formatting, links, emojis, and more. For more inform

![Screenshot of the new issue form, with a title and body filled in.](/assets/images/help/issues/issue-title-body.png)

{% ifversion task-lists-v1 %}

## Adding a task list

It can be helpful to break large issues into smaller tasks, or to track multiple related issues in a single larger issue. Add a task list to your issue by prefacing list items with `[ ]`. Reference existing issues by issue number or URL. You can use plain text to track tasks that don't have a corresponding issue and convert them to issues later. For more information, see "[AUTOTITLE](/get-started/writing-on-github/working-with-advanced-formatting/about-task-lists)."

![Screenshot of the new issue form, with the title and body filled in. The body includes the Markdown for a task list.](/assets/images/help/issues/issue-task-list-raw.png)
{% endif %}

## Adding labels

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ If you are a repository maintainer, take these steps to manage and standardize t

Pull request templates let you customize and standardize the information you'd like to be included when someone creates a pull request in your repository. When you add a pull request template to your repository, project contributors will automatically see the template's contents in the pull request body. For more information, see "[AUTOTITLE](/communities/using-templates-to-encourage-useful-issues-and-pull-requests/creating-a-pull-request-template-for-your-repository)."

{% ifversion task-lists-v1 %} You can use pull request templates to standardize the review process for your repository. For example, you can include a list of tasks that you would like authors to complete before merging their pull requests, by adding a task list to the template. For more information, see "[AUTOTITLE](/get-started/writing-on-github/working-with-advanced-formatting/about-task-lists)."{% endif %}
You can use pull request templates to standardize the review process for your repository. For example, you can include a list of tasks that you would like authors to complete before merging their pull requests, by adding a task list to the template. For more information, see "[AUTOTITLE](/get-started/writing-on-github/working-with-advanced-formatting/about-task-lists)."

You can request that contributors include an issue reference in their pull request body, so that merging the pull request will automatically close the issue. For more information, see "[AUTOTITLE](/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)."

Expand Down
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@
"@graphql-tools/load": "^8.0.0",
"@octokit/rest": "^20.1.0",
"@playwright/test": "1.44.0",
"@types/accept-language-parser": "1.5.6",
"@types/connect-datadog": "0.0.10",
"@types/connect-timeout": "0.0.39",
"@types/cookie": "0.6.0",
Expand Down
2 changes: 1 addition & 1 deletion src/frame/middleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from './set-fastly-surrogate-key.js'
import handleErrors from '@/observability/middleware/handle-errors'
import handleNextDataPath from './handle-next-data-path'
import detectLanguage from '@/languages/middleware/detect-language.js'
import detectLanguage from '@/languages/middleware/detect-language'
import reloadTree from './reload-tree.js'
import context from './context/context.js'
import shortVersions from '@/versions/middleware/short-versions.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import languages, { languageKeys } from '#src/languages/lib/languages.js'
import type { Request, Response, NextFunction } from 'express'
import parser from 'accept-language-parser'
import type { Language as parserLanguage } from 'accept-language-parser'

import { USER_LANGUAGE_COOKIE_NAME } from '#src/frame/lib/constants.js'
import languages, { languageKeys } from '@/languages/lib/languages.js'
import { USER_LANGUAGE_COOKIE_NAME } from '@/frame/lib/constants.js'
import type { ExtendedRequest, Languages } from '@/types'

const chineseRegions = [
'CN', // Mainland
Expand All @@ -10,25 +13,28 @@ const chineseRegions = [
'TW', // Taiwan
]

function translationExists(language) {
function translationExists(language: parserLanguage) {
if (language.code === 'zh') {
return chineseRegions.includes(language.region)
return language.region && chineseRegions.includes(language.region)
}
// 92BD1212-61B8-4E7A: Remove ` && !languages[language.code].wip` for the public ship of ko, fr, de, ru
return languageKeys.includes(language.code) && !languages[language.code].wip
return languageKeys.includes(language.code) && !(languages as Languages)[language.code].wip
}

function getLanguageCode(language) {
return language.code === 'cn' && chineseRegions.includes(language.region) ? 'zh' : language.code
function getLanguageCode(language: parserLanguage) {
return language.code === 'cn' && language.region && chineseRegions.includes(language.region)
? 'zh'
: language.code
}

function getUserLanguage(browserLanguages) {
function getUserLanguage(browserLanguages: parserLanguage[]) {
try {
let numTopPreferences = 1
for (let lang = 0; lang < browserLanguages.length; lang++) {
// If language has multiple regions, Chrome adds the non-region language to list
if (lang > 0 && browserLanguages[lang].code !== browserLanguages[lang - 1].code)
if (lang > 0 && browserLanguages[lang].code !== browserLanguages[lang - 1].code) {
numTopPreferences++
}
if (translationExists(browserLanguages[lang]) && numTopPreferences < 3) {
return getLanguageCode(browserLanguages[lang])
}
Expand All @@ -38,26 +44,27 @@ function getUserLanguage(browserLanguages) {
}
}

function getUserLanguageFromCookie(req) {
const value = req.cookies[USER_LANGUAGE_COOKIE_NAME]
function getUserLanguageFromCookie(req: Request) {
const value: undefined | string = req.cookies[USER_LANGUAGE_COOKIE_NAME]

// 92BD1212-61B8-4E7A: Remove ` && !languages[value].wip` for the public ship of ko, fr, de, ru
if (value && languages[value] && !languages[value].wip) {
if (value && (languages as Languages)[value] && !(languages as Languages)[value].wip) {
return value
}
}

// determine language code from a path. Default to en if no valid match
export function getLanguageCodeFromPath(path) {
export function getLanguageCodeFromPath(path: string) {
const maybeLanguage = (path.split('/')[path.startsWith('/_next/data/') ? 4 : 1] || '').slice(0, 2)
return languageKeys.includes(maybeLanguage) ? maybeLanguage : 'en'
}

export function getLanguageCodeFromHeader(req) {
export function getLanguageCodeFromHeader(req: Request) {
const browserLanguages = parser.parse(req.headers['accept-language'])
return getUserLanguage(browserLanguages)
}

export default function detectLanguage(req, res, next) {
export default function detectLanguage(req: ExtendedRequest, res: Response, next: NextFunction) {
req.language = getLanguageCodeFromPath(req.path)
// Detecting browser language by user preference
req.userLanguage = getUserLanguageFromCookie(req)
Expand Down
14 changes: 14 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,19 @@ export type ExtendedRequest = Request & {
currentCategory?: string
error?: Error
}
language?: string
userLanguage?: string
// Add more properties here as needed
}

type Language = {
name: string
code: string
hreflang: string
dir: string
wip: boolean
}

export type Languages = {
[key: string]: Language
}
Loading