Skip to content

Commit 23a481d

Browse files
authored
Merge branch 'main' into pwsh-commands
2 parents da18e59 + bf941bc commit 23a481d

File tree

122 files changed

+703
-556
lines changed

Some content is hidden

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

122 files changed

+703
-556
lines changed

.github/workflows/azure-preview-env-deploy.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ jobs:
162162
rsync -rptovR ./user-code/content/./**/*.md ./content
163163
rsync -rptovR ./user-code/assets/./**/*.png ./assets
164164
rsync -rptovR ./user-code/data/./**/*.{yml,md} ./data
165+
rsync -rptovR ./user-code/components/./**/*.{ts,tsx} ./components
166+
rsync -rptovR ./user-code/lib/./**/*.{js,ts,json} ./lib
167+
rsync -rptovR ./user-code/middleware/./**/*.{js,ts} ./middleware
168+
rsync -rptovR ./user-code/pages/./**/*.{tsx} ./pages
169+
rsync -rptovR ./user-code/stylesheets/./**/*.{scss} ./stylesheets
165170
166171
# In addition to making the final image smaller, we also save time by not sending unnecessary files to the docker build context
167172
- name: 'Prune for preview env'

.github/workflows/prod-build-deploy-azure.yml renamed to .github/workflows/azure-prod-build-deploy.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Production (Azure) - Build and Deploy
1+
name: Azure Production - Build and Deploy
22

33
# **What it does**: Builds and deploys the default branch to production
44
# **Why we have it**: To enable us to deploy the latest to production whenever necessary rather than relying on PR merges.
@@ -21,10 +21,10 @@ concurrency:
2121
cancel-in-progress: false
2222

2323
jobs:
24-
build-and-deploy-prod-azure:
24+
azure-prod-build-and-deploy:
2525
if: ${{ github.repository == 'github/docs-internal' }}
2626
runs-on: ubuntu-latest
27-
timeout-minutes: 15
27+
timeout-minutes: 20
2828
environment:
2929
name: production
3030
url: 'https://docs.github.com'
43.9 KB
Loading
32.9 KB
Loading
18.7 KB
Loading
29 KB
Loading
38.4 KB
Loading
43.1 KB
Loading
36.3 KB
Loading

components/page-header/LanguagePicker.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { useRouter } from 'next/router'
2+
import Cookies from 'js-cookie'
3+
24
import { Link } from 'components/Link'
35
import { useLanguages } from 'components/context/LanguagesContext'
46
import { Picker } from 'components/ui/Picker'
57
import { useTranslation } from 'components/hooks/useTranslation'
68

9+
// This value is replicated in two places! See middleware/detect-language.js
10+
const PREFERRED_LOCALE_COOKIE_NAME = 'preferredlang'
11+
712
type Props = {
813
variant?: 'inline'
914
}
@@ -22,6 +27,22 @@ export const LanguagePicker = ({ variant }: Props) => {
2227
// in a "denormalized" way.
2328
const routerPath = router.asPath.split('#')[0]
2429

30+
function rememberPreferredLanguage(code: string) {
31+
try {
32+
Cookies.set(PREFERRED_LOCALE_COOKIE_NAME, code, {
33+
expires: 365,
34+
secure: document.location.protocol !== 'http:',
35+
})
36+
} catch (err) {
37+
// You can never be too careful because setting a cookie
38+
// can fail. For example, some browser
39+
// extensions disallow all setting of cookies and attempts
40+
// at the `document.cookie` setter could throw. Just swallow
41+
// and move on.
42+
console.warn('Unable to set preferred language cookie', err)
43+
}
44+
}
45+
2546
return (
2647
<Picker
2748
variant={variant}
@@ -33,7 +54,13 @@ export const LanguagePicker = ({ variant }: Props) => {
3354
text: lang.nativeName || lang.name,
3455
selected: lang === selectedLang,
3556
item: (
36-
<Link href={routerPath} locale={lang.code}>
57+
<Link
58+
href={routerPath}
59+
locale={lang.code}
60+
onClick={() => {
61+
rememberPreferredLanguage(lang.code)
62+
}}
63+
>
3764
{lang.nativeName ? (
3865
<>
3966
<span lang={lang.code}>{lang.nativeName}</span> (

0 commit comments

Comments
 (0)