@jetbrains/kotlin-web-site-ui 4.14.6-alpha.4 → 4.14.7-alpha.2

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.
@@ -2,6 +2,7 @@ import React__default, { useState } from 'react';
2
2
  import Button from '@rescui/button';
3
3
  import { useTextStyles } from '@rescui/typography';
4
4
  import classNames from 'classnames';
5
+ import { toAbsoluteUrl } from '../../search-wrapper/to-absolute-url.js';
5
6
  import styles from './chapters.module.pcss.js';
6
7
  const MAX_INIT_CHAPTERS_NUMBER = 3;
7
8
 
@@ -37,7 +38,7 @@ const Chapters = ({
37
38
  mode: 'clear',
38
39
  hardness: 'hard'
39
40
  })),
40
- href: baseUrl + url,
41
+ href: toAbsoluteUrl(url, baseUrl),
41
42
  id: chapterId,
42
43
  dangerouslySetInnerHTML: {
43
44
  __html: title
@@ -4,6 +4,7 @@ import { useTextStyles } from '@rescui/typography';
4
4
  import getExtendedHits from './get-extended-hits.js';
5
5
  import { Chapters } from '../chapters/chapters.js';
6
6
  import SearchContext from '../../search-wrapper/search-context.js';
7
+ import { toAbsoluteUrl } from '../../search-wrapper/to-absolute-url.js';
7
8
  import styles from './hit-list.module.pcss.js';
8
9
 
9
10
  const HitList = ({
@@ -34,7 +35,7 @@ const HitList = ({
34
35
  mode: 'clear',
35
36
  hardness: 'hard'
36
37
  })),
37
- href: baseUrl + url,
38
+ href: toAbsoluteUrl(url, baseUrl),
38
39
  dangerouslySetInnerHTML: {
39
40
  __html: title
40
41
  }
@@ -2,6 +2,7 @@ import React__default, { useContext } from 'react';
2
2
  import { useTextStyles } from '@rescui/typography';
3
3
  import styles from './result.module.pcss.js';
4
4
  import SearchContext from '../../search-wrapper/search-context.js';
5
+ import { toAbsoluteUrl } from '../../search-wrapper/to-absolute-url.js';
5
6
 
6
7
  const Result = ({
7
8
  hit
@@ -13,7 +14,7 @@ const Result = ({
13
14
  const hitTitle = !hit.mainTitle || hit.title === hit.mainTitle ? hit.highlightedTitle : `${hit.mainTitle}: ${hit.highlightedTitle}`;
14
15
  return React__default.createElement("a", {
15
16
  className: styles.result,
16
- href: baseUrl + hit.url
17
+ href: toAbsoluteUrl(hit.url, baseUrl)
17
18
  }, React__default.createElement("div", {
18
19
  className: styles.resultTitle
19
20
  }, React__default.createElement("div", {
@@ -17,9 +17,6 @@ const SearchWrapper = ({
17
17
  const {
18
18
  search
19
19
  } = initSearch(searchConfig);
20
- const {
21
- baseUrl = ''
22
- } = searchConfig;
23
20
  const [type, setType] = useState(QUICK_SEARCH);
24
21
  const [matching, setMatching] = useState(matchingOptions[0].value);
25
22
  const [searchQueryState, setSearchQueryState] = useState(''); // router
@@ -36,7 +33,7 @@ const SearchWrapper = ({
36
33
  updateQueryString: () => {},
37
34
  searchQueryState,
38
35
  setSearchQueryState,
39
- baseUrl
36
+ baseUrl: searchConfig.baseUrl ?? ''
40
37
  }
41
38
  }, children);
42
39
  };
@@ -0,0 +1,6 @@
1
+ function toAbsoluteUrl(url, baseUrl) {
2
+ if (!url.startsWith('/')) return url;
3
+ return baseUrl.replace(/\/$/, '') + url;
4
+ }
5
+
6
+ export { toAbsoluteUrl };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jetbrains/kotlin-web-site-ui",
3
3
  "description": "UI components for Kotlin web sites development",
4
- "version": "4.14.6-alpha.4",
4
+ "version": "4.14.7-alpha.2",
5
5
  "license": "Apache-2.0",
6
6
  "author": "JetBrains",
7
7
  "files": [