Skip to content

Commit 2f6068f

Browse files
authored
Merge pull request #953 from ArmDeveloperEcosystem/copy-link-url
Copy link url
2 parents db3b006 + 3b038f1 commit 2f6068f

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

  • themes/arm-design-system-hugo-theme

themes/arm-design-system-hugo-theme/layouts/partials/package-display/table.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313
<tbody id="sw-tablebody">
1414
{{ $id_index := 0}}
1515
{{ $os := .context.Params.os }}
16-
{{ $dashboard_page_path := .context.RelPermalink | strings.TrimRight "/" }}
16+
{{ $dashboard_page_path := .context.RelPermalink }}
17+
{{ if eq .context.Site.BaseURL "/" }}
18+
{{ $base_path := (.context.Site.Params.dashboard_base_path | default "/ecosystem-dashboard") | strings.TrimRight "/" }}
19+
{{ if ne $base_path "" }}
20+
{{ $dashboard_page_path = printf "%s/%s" $base_path ($dashboard_page_path | strings.TrimLeft "/") }}
21+
{{ end }}
22+
{{ end }}
1723
{{ range .packages }}
1824

1925
{{ $id_index = add $id_index 1 }}

themes/arm-design-system-hugo-theme/static/js/eco-dashboard/search.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,26 @@ function normalizePackageName(input) {
5959
}
6060

6161
function getDashboardPath(dashboardPath) {
62-
if (dashboardPath) {
63-
return dashboardPath.replace(/\/$/, '') || '/';
62+
let normalizedPath = dashboardPath;
63+
64+
if (!normalizedPath) {
65+
normalizedPath = window.location.pathname;
66+
}
67+
68+
if (!normalizedPath) {
69+
return '/';
70+
}
71+
72+
normalizedPath = normalizedPath.trim();
73+
if (!normalizedPath.startsWith('/')) {
74+
normalizedPath = '/' + normalizedPath;
75+
}
76+
77+
if (!normalizedPath.endsWith('/')) {
78+
normalizedPath = normalizedPath + '/';
6479
}
6580

66-
return window.location.pathname.replace(/\/$/, '') || '/';
81+
return normalizedPath;
6782
}
6883

6984
function buildPackageDashboardUrl(packageSlug, dashboardPath) {

0 commit comments

Comments
 (0)