File tree Expand file tree Collapse file tree 9 files changed +39
-6
lines changed Expand file tree Collapse file tree 9 files changed +39
-6
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export type PageContext = {
21
21
} ;
22
22
23
23
type Props = {
24
+ slug : string ;
24
25
children ?: React . ReactNode ;
25
26
data ?: {
26
27
file ?: {
@@ -46,6 +47,7 @@ export function BasePage({
46
47
sidebar,
47
48
children,
48
49
prependToc,
50
+ slug,
49
51
} : Props ) {
50
52
const tx = getCurrentTransaction ( ) ;
51
53
if ( tx ) {
@@ -67,6 +69,7 @@ export function BasePage({
67
69
title = { seoTitle ?? title ?? 'Sentry Docs' }
68
70
description = { pageDescription }
69
71
noindex = { pageContext . noindex }
72
+ slug = { slug }
70
73
/>
71
74
72
75
< div className = "row" >
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ const detailsQuery = graphql`
16
16
` ;
17
17
18
18
type Props = {
19
+ slug : string ;
19
20
title : string ;
20
21
description ?: string ;
21
22
keywords ?: string [ ] ;
@@ -45,9 +46,16 @@ export function BaseSEO({
45
46
keywords = [ ] ,
46
47
title,
47
48
noindex,
49
+ slug,
48
50
} : ChildProps ) {
49
51
const metaDescription = description || data . site . siteMetadata . description ;
50
52
53
+ // slug === '' is the homepage and a valid value
54
+ const canonical =
55
+ data . site . siteMetadata . sitePath && ( slug || slug === '' )
56
+ ? `https://${ data . site . siteMetadata . sitePath } /${ slug } `
57
+ : false ;
58
+
51
59
return (
52
60
< Helmet
53
61
htmlAttributes = { {
@@ -123,7 +131,9 @@ export function BaseSEO({
123
131
: [ ]
124
132
)
125
133
. concat ( meta ) }
126
- />
134
+ >
135
+ { canonical && < link rel = "canonical" href = { canonical } /> }
136
+ </ Helmet >
127
137
) ;
128
138
}
129
139
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ function NotFoundPage() {
16
16
< SEO
17
17
title = "Page Not Found"
18
18
description = "We couldn’t find the page you were looking for."
19
+ slug = "404/"
19
20
/>
20
21
< h1 > Page Not Found</ h1 >
21
22
< p > We couldn't find the page you were looking for.</ p >
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ function IndexPage() {
60
60
61
61
return (
62
62
< div className = "index-wrapper" >
63
- < SEO title = "Sentry Documentation" />
63
+ < SEO title = "Sentry Documentation" slug = "" />
64
64
< div className = "hero-section" >
65
65
< div className = "index-container" >
66
66
< div className = "index-navbar" >
Original file line number Diff line number Diff line change @@ -10,8 +10,12 @@ export default function ApiDoc(props) {
10
10
const {
11
11
data : { allOpenApi, apiDescription} ,
12
12
} = props ;
13
+
14
+ // remove leading '/'
15
+ const slug = props . location . pathname . replace ( / ^ \/ / , '' ) ;
16
+
13
17
return (
14
- < BasePage sidebar = { < ApiSidebar /> } { ...props } >
18
+ < BasePage sidebar = { < ApiSidebar /> } slug = { slug } { ...props } >
15
19
{ apiDescription && < Content file = { apiDescription } /> }
16
20
< ul data-noindex >
17
21
{ allOpenApi . edges . map ( ( { node : { path} } ) => (
Original file line number Diff line number Diff line change @@ -172,11 +172,14 @@ export default function ApiPage(props) {
172
172
? [ 'RESPONSE' , 'SCHEMA' ]
173
173
: [ 'RESPONSE' ] ;
174
174
175
+ // remove leading '/'
176
+ const slug = props . location . pathname . replace ( / ^ \/ / , '' ) ;
177
+
175
178
useEffect ( ( ) => {
176
179
Prism . highlightAll ( ) ;
177
180
} , [ ] ) ;
178
181
return (
179
- < BasePage sidebar = { < ApiSidebar /> } { ...props } >
182
+ < BasePage sidebar = { < ApiSidebar /> } slug = { slug } { ...props } >
180
183
< div className = "row" >
181
184
< div className = "col-12" >
182
185
< div className = "api-block" >
Original file line number Diff line number Diff line change @@ -13,8 +13,12 @@ export default function Doc(props: any) {
13
13
} else if ( props . path . startsWith ( '/contributing/' ) ) {
14
14
sidebar = < InternalDocsSidebar /> ;
15
15
}
16
+
17
+ // remove leading '/'
18
+ const slug = props . location . pathname . replace ( / ^ \/ / , '' ) ;
19
+
16
20
return (
17
- < BasePage sidebar = { sidebar } { ...props } >
21
+ < BasePage sidebar = { sidebar } slug = { slug } { ...props } >
18
22
< Content file = { props . data . file } />
19
23
</ BasePage >
20
24
) ;
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ type Props = {
10
10
data : {
11
11
file : any ;
12
12
} ;
13
+ location : {
14
+ pathname : string ;
15
+ } ;
13
16
pageContext : {
14
17
platform : {
15
18
name : string ;
@@ -36,9 +39,14 @@ export default function Platform(props: Props) {
36
39
: `${ props . pageContext . title } for ${
37
40
( props . pageContext . guide || props . pageContext . platform ) . title
38
41
} `;
42
+
43
+ // remove leading '/'
44
+ const slug = props . location . pathname . replace ( / ^ \/ / , '' ) ;
45
+
39
46
return (
40
47
< BasePage
41
48
{ ...props }
49
+ slug = { slug }
42
50
seoTitle = { seoTitle }
43
51
prependToc = { < PlatformSdkDetail /> }
44
52
sidebar = {
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ export default function WizardDebug({
10
10
} ,
11
11
} ) {
12
12
return (
13
- < BasePage pageContext = { { title : 'Wizard Previews' } } >
13
+ < BasePage pageContext = { { title : 'Wizard Previews' } } slug = "wizard-debug/" >
14
14
< ul >
15
15
{ nodes
16
16
. sort ( ( a , b ) =>
You can’t perform that action at this time.
0 commit comments