|
2 | 2 | import { onMount } from 'svelte'; |
3 | 3 | import { page } from '$app/stores'; |
4 | 4 | import { getUserStore, globalMenuStore } from '$lib/helpers/store'; |
| 5 | + import { getCleanUrl } from '$lib/helpers/utils/common'; |
5 | 6 |
|
6 | 7 | let { |
7 | 8 | htmlTagId = 'embedding-page', |
|
25 | 26 |
|
26 | 27 | onMount(() => { |
27 | 28 | const menuUnsubscribe = globalMenuStore.subscribe((/** @type {import('$pluginTypes').PluginMenuDefModel[]} */ menu) => { |
28 | | - const url = getPathUrl(); |
29 | | - let found = menu.find(x => x.link === url); |
| 29 | + const url = getCleanPath(getPathUrl()); |
| 30 | + let found = menu.find(x => getCleanPath(x.link) === url); |
30 | 31 | label = found?.label || ''; |
31 | 32 | if (!found?.embeddingInfo) { |
32 | | - const subFound = menu.find(x => !!x.subMenu?.find(y => y.link === url)); |
33 | | - found = subFound?.subMenu?.find(x => x.link === url); |
| 33 | + const subFound = menu.find(x => !!x.subMenu?.find(y => getCleanPath(y.link) === url)); |
| 34 | + found = subFound?.subMenu?.find(x => getCleanPath(x.link) === url); |
34 | 35 | label = found?.label || ''; |
35 | 36 | } |
36 | 37 | embed(found?.embeddingInfo || null); |
|
77 | 78 | } |
78 | 79 | } |
79 | 80 |
|
| 81 | + /** @param {string} url */ |
| 82 | + const getCleanPath = (url) => { |
| 83 | + return getCleanUrl((url || '').split('?')[0]); |
| 84 | + }; |
| 85 | +
|
80 | 86 | const getPathUrl = () => { |
81 | | - const path = $page.url.pathname; |
82 | | - return path?.startsWith('/') ? path.substring(1) : path; |
| 87 | + return $page.url.pathname || ''; |
83 | 88 | }; |
84 | 89 | </script> |
85 | 90 |
|
|
0 commit comments