@@ -18,6 +18,8 @@ import { getPagePath, resolvePageId } from './pages';
18
18
export interface ResolvedContentRef {
19
19
/** Text to render in the content ref */
20
20
text : string ;
21
+ /** Additional sub text to render in the content ref */
22
+ subText ?: string ;
21
23
/** Emoji associated with the reference */
22
24
emoji ?: string ;
23
25
/** URL to open for the content ref */
@@ -103,10 +105,14 @@ export async function resolveContentRef(
103
105
return resolveContentRefInSpace ( contentRef . space , contentRef ) ;
104
106
}
105
107
106
- const page =
108
+ const resolvePageResult =
107
109
! contentRef . page || contentRef . page === activePage ?. id
108
110
? activePage
109
- : resolvePageId ( pages , contentRef . page ) ?. page ;
111
+ ? { page : activePage , ancestors : [ ] }
112
+ : undefined
113
+ : resolvePageId ( pages , contentRef . page ) ;
114
+
115
+ const page = resolvePageResult ?. page ;
110
116
if ( ! page ) {
111
117
return null ;
112
118
}
@@ -134,7 +140,13 @@ export async function resolveContentRef(
134
140
}
135
141
}
136
142
} else {
137
- text = page . title ;
143
+ const parentPage = ( resolvePageResult ?. ancestors || [ ] ) . slice ( - 1 ) . pop ( ) ;
144
+ // When the looked up ref was a page group we use the page group title as resolved ref text.
145
+ // Otherwise use the resolved page title.
146
+ text =
147
+ parentPage && contentRef . page === parentPage . id && parentPage . type === 'group'
148
+ ? parentPage . title
149
+ : page . title ;
138
150
emoji = isCurrentPage ? undefined : page . emoji ;
139
151
}
140
152
@@ -245,12 +257,21 @@ async function resolveContentRefInSpace(spaceId: string, contentRef: ContentRef)
245
257
baseUrl += '/' ;
246
258
}
247
259
248
- return resolveContentRef ( contentRef , {
260
+ const resolved = await resolveContentRef ( contentRef , {
249
261
space,
250
262
revisionId : space . revision ,
251
263
pages,
252
264
baseUrl,
253
265
} ) ;
266
+
267
+ if ( ! resolved ) {
268
+ return null ;
269
+ }
270
+
271
+ return {
272
+ ...resolved ,
273
+ subText : space . title ,
274
+ } ;
254
275
}
255
276
256
277
export function resolveContentRefWithFiles (
0 commit comments