Skip to content

Commit 3f24897

Browse files
committed
Merge branch 'main' of https://github.com/github/docs-internal into grace-header-styling
2 parents 29e6a7f + ab0d5e0 commit 3f24897

File tree

74 files changed

+971
-181
lines changed

Some content is hidden

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

74 files changed

+971
-181
lines changed
Loading
Loading
Loading
Loading
Loading

components/DefaultLayout.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { useTranslation } from './hooks/useTranslation'
1111

1212
type Props = { children?: React.ReactNode }
1313
export const DefaultLayout = (props: Props) => {
14-
const { builtAssets, expose, page, error, isHomepageVersion } = useMainContext()
14+
const { builtAssets, page, error, isHomepageVersion } = useMainContext()
1515
const { t } = useTranslation('errors')
1616
return (
1717
<div className="d-lg-flex">
@@ -22,7 +22,6 @@ export const DefaultLayout = (props: Props) => {
2222
<title>{page.fullTitle}</title>
2323
) : null}
2424

25-
<script id="expose" type="application/json" dangerouslySetInnerHTML={{ __html: expose }} />
2625
<script src={builtAssets.main.js} />
2726

2827
{/* For Google and Bots */}

components/Search.tsx

+3-6
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,11 @@ export function Search({ isStandalone = false, updateSearchParams = true, childr
3030
const { currentVersion } = useVersion()
3131

3232
// Figure out language and version for index
33-
const { expose } = useMainContext()
34-
const {
35-
searchOptions: { languages, versions, nonEnterpriseDefaultVersion },
36-
} = JSON.parse(expose)
33+
const { languages, searchVersions, nonEnterpriseDefaultVersion } = useMainContext()
3734
const router = useRouter()
3835
// fall back to the non-enterprise default version (FPT currently) on the homepage, 404 page, etc.
39-
const version = versions[currentVersion] || versions[nonEnterpriseDefaultVersion]
40-
const language = (languages.includes(router.locale) && router.locale) || 'en'
36+
const version = searchVersions[currentVersion] || searchVersions[nonEnterpriseDefaultVersion]
37+
const language = (Object.keys(languages).includes(router.locale || '') && router.locale) || 'en'
4138

4239
// If the user shows up with a query in the URL, go ahead and search for it
4340
useEffect(() => {

components/article/ArticleTitle.tsx

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Tooltip, Link } from '@primer/components'
1+
import { Tooltip } from '@primer/components'
22
import { PrinterIcon } from './PrinterIcon'
33

44
type Props = {
@@ -10,10 +10,8 @@ export const ArticleTitle = ({ children }: Props) => {
1010
<h1 className="my-4 border-bottom-0">{children}</h1>
1111
<div className="d-none d-lg-block ml-2">
1212
<Tooltip aria-label="Print this article" noDelay direction="n">
13-
<Link
14-
as="button"
15-
underline={false}
16-
muted
13+
<button
14+
className="btn-link Link--muted"
1715
onClick={() => {
1816
try {
1917
document.execCommand('print', false)
@@ -23,7 +21,7 @@ export const ArticleTitle = ({ children }: Props) => {
2321
}}
2422
>
2523
<PrinterIcon />
26-
</Link>
24+
</button>
2725
</Tooltip>
2826
</div>
2927
</div>

components/context/MainContext.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export type MainContextT = {
6969
article?: BreadcrumbT
7070
}
7171
builtAssets: { main: { js: string } }
72-
expose: string
7372
activeProducts: Array<ProductT>
7473
currentProduct?: ProductT
7574
currentLayoutName: string
@@ -106,12 +105,14 @@ export type MainContextT = {
106105
}
107106

108107
enterpriseServerVersions: Array<string>
108+
109+
searchVersions: Record<string, string>
110+
nonEnterpriseDefaultVersion: string
109111
}
110112

111113
export const getMainContextFromRequest = (req: any): MainContextT => {
112114
return {
113115
builtAssets: { main: { js: req.context.builtAssets.main.js } },
114-
expose: req.context.expose,
115116
breadcrumbs: req.context.breadcrumbs || {},
116117
activeProducts: req.context.activeProducts,
117118
currentProduct: req.context.productMap[req.context.currentProduct] || null,
@@ -179,6 +180,8 @@ export const getMainContextFromRequest = (req: any): MainContextT => {
179180
? getCurrentProductTree(req.context.currentProductTree)
180181
: null,
181182
featureFlags: {},
183+
searchVersions: req.context.searchVersions,
184+
nonEnterpriseDefaultVersion: req.context.nonEnterpriseDefaultVersion,
182185
}
183186
}
184187

components/context/ProductLandingContext.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export type ProductLandingContextT = {
4848
viewAllHref?: string // If provided, adds a "View All ->" to the header
4949
articles: Array<FeaturedLink>
5050
}>
51-
changelog: { label: string; prefix: string }
5251
changelogUrl?: string
5352
whatsNewChangelog?: Array<{ href: string; title: string; date: string }>
5453
tocItems: Array<TocItem>
@@ -85,7 +84,6 @@ export const getProductLandingContextFromRequest = (req: any): ProductLandingCon
8584
'beta_product',
8685
'intro',
8786
'product_video',
88-
'changelog',
8987
]),
9088
product: {
9189
href: productTree.href,

components/context/TocLandingContext.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pick from 'lodash/pick'
12
import { createContext, useContext } from 'react'
23

34
export type TocItem = {
@@ -26,10 +27,13 @@ export const useTocLandingContext = (): TocLandingContextT => {
2627
}
2728

2829
export const getTocLandingContextFromRequest = (req: any): TocLandingContextT => {
30+
console.log(req.context.genericTocFlat, req.context.genericTocNested)
2931
return {
3032
title: req.context.page.title,
3133
introPlainText: req.context.page.introPlainText,
32-
tocItems: req.context.genericTocFlat || req.context.genericTocNested || [],
34+
tocItems: (req.context.genericTocFlat || req.context.genericTocNested || []).map((obj: any) =>
35+
pick(obj, ['fullPath', 'title', 'intro'])
36+
),
3337
variant: req.context.genericTocFlat ? 'expanded' : 'compact',
3438
}
3539
}

components/landing/CodeExampleCard.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { RepoIcon } from '@primer/octicons-react'
22
import { CodeExample } from 'components/context/ProductLandingContext'
3+
import { TruncateLines } from 'components/TruncateLines'
34

45
type Props = {
56
example: CodeExample
@@ -28,7 +29,9 @@ export const CodeExampleCard = ({ example }: Props) => {
2829
</div>
2930
<footer className="border-top p-4 color-text-secondary d-flex flex-items-center">
3031
<RepoIcon className="flex-shrink-0" />
31-
<span className="ml-2 text-mono text-small color-text-link">{example.href}</span>
32+
<TruncateLines as="span" maxLines={1} className="ml-2 text-mono text-small color-text-link line-break-anywhere">
33+
{example.href}
34+
</TruncateLines>
3235
</footer>
3336
</a>
3437
)

components/landing/FeaturedArticles.tsx

+5-9
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@ import { useTranslation } from 'components/hooks/useTranslation'
88
import { TruncateLines } from 'components/TruncateLines'
99

1010
export const FeaturedArticles = () => {
11-
const {
12-
featuredArticles = [],
13-
changelog,
14-
whatsNewChangelog,
15-
changelogUrl,
16-
} = useProductLandingContext()
11+
const { featuredArticles = [], whatsNewChangelog, changelogUrl } = useProductLandingContext()
12+
const hasWhatsNewChangelog = whatsNewChangelog && whatsNewChangelog.length > 0
1713
const { t } = useTranslation('toc')
1814

1915
return (
@@ -22,7 +18,7 @@ export const FeaturedArticles = () => {
2218
return (
2319
<div
2420
key={section.label + i}
25-
className={cx('col-12 mb-4 mb-lg-0', changelog ? 'col-lg-4' : 'col-lg-6')}
21+
className={cx('col-12 mb-4 mb-lg-0', hasWhatsNewChangelog ? 'col-lg-4' : 'col-lg-6')}
2622
>
2723
<ArticleList
2824
title={section.label}
@@ -33,8 +29,8 @@ export const FeaturedArticles = () => {
3329
)
3430
})}
3531

36-
{changelog && (
37-
<div className={cx('col-12 mb-4 mb-lg-0', changelog ? 'col-lg-4' : 'col-lg-6')}>
32+
{hasWhatsNewChangelog && (
33+
<div className={cx('col-12 mb-4 mb-lg-0 col-lg-4')}>
3834
<ArticleList
3935
title={t('whats_new')}
4036
viewAllHref={changelogUrl}

components/landing/ProductLanding.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const ProductLanding = () => {
6868
</div>
6969
)}
7070

71-
<LandingSection sectionLink="all-docs" title={`All ${shortTitle} Docs`}>
71+
<LandingSection sectionLink="all-docs" title={`All ${shortTitle} docs`}>
7272
<ProductArticlesList />
7373
</LandingSection>
7474
</DefaultLayout>

0 commit comments

Comments
 (0)