@@ -7,10 +7,11 @@ import { componentMaxHeight, HEADER_HEIGHT, HEADER_BOTTOM_MARGIN } from '@ably/u
7
7
8
8
import { LanguageSelector } from './LanguageSelector' ;
9
9
import { useLayoutContext } from 'src/contexts/layout-context' ;
10
+ import { productData } from 'src/data' ;
11
+ import { LanguageKey } from 'src/data/languages/types' ;
10
12
import { languageInfo } from 'src/data/languages' ;
11
13
import { ActivePage , sidebarAlignmentClasses , sidebarAlignmentStyles } from './utils/nav' ;
12
14
import { INKEEP_ASK_BUTTON_HEIGHT } from './utils/heights' ;
13
- import { LanguageKey } from 'src/data/languages/types' ;
14
15
15
16
type SidebarHeader = {
16
17
id : string ;
@@ -30,35 +31,36 @@ const externalLinks = (
30
31
activePage : ActivePage ,
31
32
location : WindowLocation ,
32
33
) : { label : string ; icon : IconName ; link : string ; type : string } [ ] => {
34
+ if ( ! activePage ) {
35
+ return [ ] ;
36
+ }
37
+
33
38
let githubEditPath = '#' ;
34
- let requestPath = '#' ;
35
-
36
- if ( activePage ) {
37
- const githubPathName = location . pathname . replace ( 'docs/' , '' ) ;
38
-
39
- if ( customGithubPaths [ githubPathName ] ) {
40
- githubEditPath = customGithubPaths [ githubPathName ] ;
41
- } else if ( activePage . template === 'mdx' ) {
42
- githubEditPath =
43
- githubBasePathMDX + ( activePage . page . index ? `${ githubPathName } /index.mdx` : `${ githubPathName } .mdx` ) ;
44
- } else {
45
- githubEditPath =
46
- githubBasePathTextile +
47
- ( activePage . page . index ? `${ githubPathName } /index.textile` : `${ githubPathName } .textile` ) ;
48
- }
39
+ const githubPathName = location . pathname . replace ( 'docs/' , '' ) ;
40
+
41
+ if ( customGithubPaths [ githubPathName ] ) {
42
+ githubEditPath = customGithubPaths [ githubPathName ] ;
43
+ } else if ( activePage . template === 'mdx' ) {
44
+ githubEditPath =
45
+ githubBasePathMDX + ( activePage . page . index ? `${ githubPathName } /index.mdx` : `${ githubPathName } .mdx` ) ;
46
+ } else {
47
+ githubEditPath =
48
+ githubBasePathTextile + ( activePage . page . index ? `${ githubPathName } /index.textile` : `${ githubPathName } .textile` ) ;
49
+ }
49
50
50
- const language = new URLSearchParams ( location . search ) . get ( 'lang' ) as LanguageKey ;
51
- const requestTitle = `Change request for: ${ activePage . page . link } ` ;
52
- const requestBody = encodeURIComponent ( `
51
+ const language = activePage . languages . length > 0 ? activePage . language : null ;
52
+ const requestTitle = `Change request for: ${ activePage . page . link } ` ;
53
+ const requestBody = encodeURIComponent ( `
53
54
**Page name**: ${ activePage . page . name }
54
55
**URL**: [${ activePage . page . link } ](https://ably.com${ activePage . page . link } )
55
56
${ language && languageInfo [ language ] ? `Language: **${ languageInfo [ language ] . label } **` : '' }
56
57
57
58
**Requested change or enhancement**:
58
59
` ) ;
59
60
60
- requestPath = `${ requestBasePath } ?title=${ requestTitle } &body=${ requestBody } ` ;
61
- }
61
+ const requestPath = `${ requestBasePath } ?title=${ requestTitle } &body=${ requestBody } ` ;
62
+ const prompt = `Tell me more about ${ activePage . product ? productData [ activePage . product ] ?. nav . name : 'Ably' } 's '${ activePage . page . name } ' feature from https://ably.com${ activePage . page . link } ${ language ? ` for ${ languageInfo [ language ] ?. label } ` : '' } ` ;
63
+ const gptPath = `https://chatgpt.com/?q=${ encodeURIComponent ( prompt ) } ` ;
62
64
63
65
return [
64
66
{
@@ -68,6 +70,7 @@ const externalLinks = (
68
70
type : 'github' ,
69
71
} ,
70
72
{ label : 'Request changes' , icon : 'icon-gui-hand-raised-outline' , link : requestPath , type : 'request' } ,
73
+ { label : 'Open in ChatGPT' , icon : 'icon-tech-openai' , link : gptPath , type : 'llm' } ,
71
74
] ;
72
75
} ;
73
76
@@ -253,7 +256,7 @@ const RightSidebar = () => {
253
256
< div
254
257
className = { cn (
255
258
'flex items-center p-4' ,
256
- index === 0 && 'border-b border-neutral-300 dark:border-neutral-1000' ,
259
+ index > 0 && 'border-t border-neutral-300 dark:border-neutral-1000' ,
257
260
) }
258
261
>
259
262
< div className = "flex-1 flex items-center gap-3" >
0 commit comments