@gsa-tts/graymatter-ui 0.4.16 → 0.4.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
import ApiDocSubNavList from './ApiDocSubNavList.svelte';
|
|
6
6
|
|
|
7
7
|
const { data = null } = $props();
|
|
8
|
+
// TODO: remove legacy /api/documentation path once all consuming apps migrate
|
|
9
|
+
const API_DOC_PATHS = ['/api-documentation', '/api/documentation'];
|
|
10
|
+
|
|
11
|
+
function isApiDocumentationPath(path: string | null | undefined) {
|
|
12
|
+
if (!path) return false;
|
|
13
|
+
return API_DOC_PATHS.some(apiPath => path.includes(apiPath));
|
|
14
|
+
}
|
|
8
15
|
|
|
9
16
|
const sections = $derived(() =>
|
|
10
17
|
!Array.isArray(data) &&
|
|
@@ -232,8 +239,7 @@
|
|
|
232
239
|
// Only do this if we're on the API documentation page (where this component exists)
|
|
233
240
|
if (data && effectiveSelectedId() && typeof window !== 'undefined') {
|
|
234
241
|
const currentPath = window.location.pathname;
|
|
235
|
-
const isApiDocumentationPage =
|
|
236
|
-
currentPath.includes('/api/documentation');
|
|
242
|
+
const isApiDocumentationPage = isApiDocumentationPath(currentPath);
|
|
237
243
|
|
|
238
244
|
if (isApiDocumentationPage) {
|
|
239
245
|
const restoredItem = findItemById(data, effectiveSelectedId()!);
|
|
@@ -259,13 +265,13 @@
|
|
|
259
265
|
// Check if we're navigating TO the documentation page (vs refreshing while on it)
|
|
260
266
|
if (typeof window !== 'undefined') {
|
|
261
267
|
const currentPath = window.location.pathname;
|
|
262
|
-
const isDocumentationPage = currentPath
|
|
268
|
+
const isDocumentationPage = isApiDocumentationPath(currentPath);
|
|
263
269
|
|
|
264
270
|
// If we're on the documentation page, check if we came from a different page
|
|
265
271
|
if (isDocumentationPage) {
|
|
266
272
|
const referrer = document.referrer;
|
|
267
273
|
const isFromDifferentPage =
|
|
268
|
-
referrer && !referrer
|
|
274
|
+
referrer && !isApiDocumentationPath(referrer);
|
|
269
275
|
|
|
270
276
|
// If we came from a different page, clear sessionStorage to reset to initial values
|
|
271
277
|
if (isFromDifferentPage) {
|
|
@@ -82,7 +82,8 @@ function headingsToNavItems(
|
|
|
82
82
|
|
|
83
83
|
// Generate navigation data dynamically from API documentation metadata
|
|
84
84
|
export function generateApiDocumentationNavData(
|
|
85
|
-
apiDocs: ApiDocMetadata[]
|
|
85
|
+
apiDocs: ApiDocMetadata[],
|
|
86
|
+
basePath = '/api-documentation'
|
|
86
87
|
): SubNavData {
|
|
87
88
|
// Sort by sortOrder
|
|
88
89
|
const sortedDocs = [...apiDocs].sort((a, b) => a.sortOrder - b.sortOrder);
|
|
@@ -97,7 +98,7 @@ export function generateApiDocumentationNavData(
|
|
|
97
98
|
return {
|
|
98
99
|
id: doc.slug,
|
|
99
100
|
title: doc.title,
|
|
100
|
-
href:
|
|
101
|
+
href: `${basePath}#${doc.slug}`,
|
|
101
102
|
children,
|
|
102
103
|
};
|
|
103
104
|
});
|