@seqera/docusaurus-theme-seqera 1.0.31-next.102 → 1.0.32-next.104

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.
@@ -1,3 +1,4 @@
1
+
1
2
  h1,
2
3
  h2,
3
4
  h3,
@@ -114,7 +114,8 @@ export default function NavbarContent() {
114
114
  <a
115
115
  className={clsx(
116
116
  'navbar__link ml-8 font-normal',
117
- pathname.startsWith('/platform-api/') && 'navbar__link--active',
117
+ pathname.replace(/\/$/, '').startsWith('/platform-api') &&
118
+ 'navbar__link--active',
118
119
  )}
119
120
  href="/platform-api/"
120
121
  aria-label="Platform API">
@@ -123,7 +124,8 @@ export default function NavbarContent() {
123
124
  <a
124
125
  className={clsx(
125
126
  'navbar__link ml-8 font-normal',
126
- pathname.startsWith('/changelog/') && 'navbar__link--active',
127
+ pathname.replace(/\/$/, '').startsWith('/changelog') &&
128
+ 'navbar__link--active',
127
129
  )}
128
130
  href="/changelog/"
129
131
  aria-label="Changelog">
@@ -17,14 +17,11 @@ export default function NavbarNavLink({
17
17
  prependBaseUrlToHref,
18
18
  ...props
19
19
  }) {
20
- // TODO all this seems hacky
21
- // {to: 'version'} should probably be forbidden, in favor of {to: '/version'}
22
20
  const toUrl = useBaseUrl(to);
23
21
  const activeBaseUrl = useBaseUrl(activeBasePath);
24
22
  const normalizedHref = useBaseUrl(href, {forcePrependBaseUrl: true});
25
23
  const isExternalLink = label && href && !isInternalUrl(href);
26
24
  const {pathname} = useLocation();
27
- // Link content is set through html XOR label
28
25
  const linkContentProps = html
29
26
  ? {dangerouslySetInnerHTML: {__html: html}}
30
27
  : {
@@ -40,7 +37,12 @@ export default function NavbarNavLink({
40
37
  ),
41
38
  };
42
39
  if (href) {
43
- const isActiveHref = !isExternalLink && pathname.startsWith(href);
40
+ const normalizedPathname = pathname.replace(/\/$/, '');
41
+ const normalizedHrefPath = href.replace(/\/$/, '');
42
+ const isActiveHref =
43
+ !isExternalLink &&
44
+ (normalizedPathname === normalizedHrefPath ||
45
+ normalizedPathname.startsWith(normalizedHrefPath + '/'));
44
46
  return (
45
47
  <Link
46
48
  href={prependBaseUrlToHref ? normalizedHref : href}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seqera/docusaurus-theme-seqera",
3
- "version": "1.0.31-next.102",
3
+ "version": "1.0.32-next.104",
4
4
  "description": "Seqera docs theme for Docusaurus",
5
5
  "author": "Seqera docs team <education@seqera.io>",
6
6
  "license": "Apache-2.0",
@@ -1,3 +1,4 @@
1
+
1
2
  h1,
2
3
  h2,
3
4
  h3,
@@ -128,13 +128,13 @@ export default function NavbarContent(): ReactNode {
128
128
  </div>
129
129
  <div className="mr-2">
130
130
  <a
131
- className={clsx('navbar__link ml-8 font-normal', pathname.startsWith('/platform-api/') && 'navbar__link--active')}
131
+ className={clsx('navbar__link ml-8 font-normal', pathname.replace(/\/$/, '').startsWith('/platform-api') && 'navbar__link--active')}
132
132
  href="/platform-api/"
133
133
  aria-label="Platform API">
134
134
  Platform API
135
135
  </a>
136
136
  <a
137
- className={clsx('navbar__link ml-8 font-normal', pathname.startsWith('/changelog/') && 'navbar__link--active')}
137
+ className={clsx('navbar__link ml-8 font-normal', pathname.replace(/\/$/, '').startsWith('/changelog') && 'navbar__link--active')}
138
138
  href="/changelog/"
139
139
  aria-label="Changelog">
140
140
  Changelog
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  import React, {type ReactNode} from 'react';
4
2
  import clsx from 'clsx';
5
3
  import Link from '@docusaurus/Link';
@@ -21,15 +19,12 @@ export default function NavbarNavLink({
21
19
  prependBaseUrlToHref,
22
20
  ...props
23
21
  }: Props): ReactNode {
24
- // TODO all this seems hacky
25
- // {to: 'version'} should probably be forbidden, in favor of {to: '/version'}
26
22
  const toUrl = useBaseUrl(to);
27
23
  const activeBaseUrl = useBaseUrl(activeBasePath);
28
24
  const normalizedHref = useBaseUrl(href, {forcePrependBaseUrl: true});
29
25
  const isExternalLink = label && href && !isInternalUrl(href);
30
26
  const {pathname} = useLocation();
31
27
 
32
- // Link content is set through html XOR label
33
28
  const linkContentProps = html
34
29
  ? {dangerouslySetInnerHTML: {__html: html}}
35
30
  : {
@@ -46,7 +41,13 @@ export default function NavbarNavLink({
46
41
  };
47
42
 
48
43
  if (href) {
49
- const isActiveHref = !isExternalLink && pathname.startsWith(href);
44
+ const normalizedPathname = pathname.replace(/\/$/, '');
45
+ const normalizedHrefPath = href.replace(/\/$/, '');
46
+ const isActiveHref =
47
+ !isExternalLink &&
48
+ (normalizedPathname === normalizedHrefPath ||
49
+ normalizedPathname.startsWith(normalizedHrefPath + '/'));
50
+
50
51
  return (
51
52
  <Link
52
53
  href={prependBaseUrlToHref ? normalizedHref : href}
@@ -73,4 +74,4 @@ export default function NavbarNavLink({
73
74
  {...linkContentProps}
74
75
  />
75
76
  );
76
- }
77
+ }