forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArticlePage.tsx
152 lines (141 loc) · 5.15 KB
/
ArticlePage.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import cx from 'classnames'
import { DefaultLayout } from 'components/DefaultLayout'
import { ArticleVersionPicker } from 'components/article/ArticleVersionPicker'
import { Breadcrumbs } from 'components/Breadcrumbs'
import { ArticleTitle } from 'components/article/ArticleTitle'
import { useArticleContext } from 'components/context/ArticleContext'
import { InfoIcon } from '@primer/octicons-react'
import { useTranslation } from 'components/hooks/useTranslation'
import { LearningTrackNav } from './LearningTrackNav'
export const ArticlePage = () => {
const {
title,
intro,
renderedPage,
contributor,
permissions,
includesPlatformSpecificContent,
defaultPlatform,
product,
miniTocItems,
currentLearningTrack,
} = useArticleContext()
const { t } = useTranslation('pages')
return (
<DefaultLayout>
<div className="container-xl px-3 px-md-6 my-4 my-lg-4">
<article className="markdown-body">
<div className="d-lg-flex flex-justify-between">
<div className="d-block d-lg-none">
<ArticleVersionPicker />
</div>
<div className="d-flex flex-items-center">
<Breadcrumbs />
</div>
<div className="d-none d-lg-block">
<ArticleVersionPicker />
</div>
</div>
<div className="article-grid-container mt-2">
<div className="article-grid-head">
<ArticleTitle>{title}</ArticleTitle>
{contributor && (
<div className="contributor-callout border rounded-1 mb-4 p-3 color-border-info color-bg-info f5">
<p>
<span className="mr-2">
<InfoIcon />
</span>
{t('contributor_callout')} <a href={contributor.URL}>{contributor.name}</a>.
</p>
</div>
)}
{intro && (
<div className="lead-mktg">
<p>{intro}</p>
</div>
)}
{permissions && (
<div
className="permissions-statement"
dangerouslySetInnerHTML={{ __html: permissions }}
/>
)}
{includesPlatformSpecificContent && (
<nav
className="UnderlineNav my-3"
data-default-platform={defaultPlatform || undefined}
>
<div className="UnderlineNav-body">
<a href="#" className="UnderlineNav-item platform-switcher" data-platform="mac">
Mac
</a>
<a
href="#"
className="UnderlineNav-item platform-switcher"
data-platform="windows"
>
Windows
</a>
<a
href="#"
className="UnderlineNav-item platform-switcher"
data-platform="linux"
>
Linux
</a>
</div>
</nav>
)}
{product && (
<div
className="product-callout border rounded-1 mb-4 p-3 color-border-success color-bg-success"
dangerouslySetInnerHTML={{ __html: product }}
/>
)}
</div>
<div className="article-grid-toc border-bottom border-xl-0 pb-4 mb-5 pb-xl-0 mb-xl-0">
<div className="article-grid-toc-content">
{miniTocItems.length > 1 && (
<>
<h2 id="in-this-article" className="f5 mb-2">
<a className="Link--primary" href="#in-this-article">
{t('miniToc')}
</a>
</h2>
<ul className="list-style-none pl-0 f5 mb-0">
{miniTocItems.map((item) => {
return (
<li
key={item.contents}
className={cx(
`ml-${item.indentationLevel * 3}`,
item.platform,
'mb-2 lh-condensed'
)}
dangerouslySetInnerHTML={{ __html: item.contents }}
/>
)
})}
</ul>
</>
)}
</div>
</div>
<div className="markdown-body">
<div
id="article-contents"
className="article-grid-body"
dangerouslySetInnerHTML={{ __html: renderedPage }}
/>
</div>
</div>
{currentLearningTrack?.trackName ? (
<div className="d-block mt-4 markdown-body">
<LearningTrackNav track={currentLearningTrack} />
</div>
) : null}
</article>
</div>
</DefaultLayout>
)
}