@@ -18,6 +18,8 @@ import { getPagePath, resolvePageId } from './pages';
1818export interface ResolvedContentRef {
1919 /** Text to render in the content ref */
2020 text : string ;
21+ /** Additional sub text to render in the content ref */
22+ subText ?: string ;
2123 /** Emoji associated with the reference */
2224 emoji ?: string ;
2325 /** URL to open for the content ref */
@@ -103,10 +105,14 @@ export async function resolveContentRef(
103105 return resolveContentRefInSpace ( contentRef . space , contentRef ) ;
104106 }
105107
106- const page =
108+ const resolvePageResult =
107109 ! contentRef . page || contentRef . page === activePage ?. id
108110 ? activePage
109- : resolvePageId ( pages , contentRef . page ) ?. page ;
111+ ? { page : activePage , ancestors : [ ] }
112+ : undefined
113+ : resolvePageId ( pages , contentRef . page ) ;
114+
115+ const page = resolvePageResult ?. page ;
110116 if ( ! page ) {
111117 return null ;
112118 }
@@ -134,7 +140,13 @@ export async function resolveContentRef(
134140 }
135141 }
136142 } 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 ;
138150 emoji = isCurrentPage ? undefined : page . emoji ;
139151 }
140152
@@ -245,12 +257,21 @@ async function resolveContentRefInSpace(spaceId: string, contentRef: ContentRef)
245257 baseUrl += '/' ;
246258 }
247259
248- return resolveContentRef ( contentRef , {
260+ const resolved = await resolveContentRef ( contentRef , {
249261 space,
250262 revisionId : space . revision ,
251263 pages,
252264 baseUrl,
253265 } ) ;
266+
267+ if ( ! resolved ) {
268+ return null ;
269+ }
270+
271+ return {
272+ ...resolved ,
273+ subText : space . title ,
274+ } ;
254275}
255276
256277export function resolveContentRefWithFiles (
0 commit comments