@alauda/doom 1.7.0 → 1.7.1

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,5 +1,5 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { NoSSR, useLang } from '@rspress/core/runtime';
2
+ import { NoSSR, useLang, usePageData } from '@rspress/core/runtime';
3
3
  import { addTrailingSlash, isExternalUrl, normalizeHref, parseUrl, removeLeadingSlash, } from '@rspress/shared';
4
4
  import { DEFAULT_PAGE_EXTENSIONS } from '@rspress/shared/constants';
5
5
  import { clsx } from 'clsx';
@@ -11,6 +11,7 @@ import { useIsPrint } from '../hooks/index.js';
11
11
  import { Directive } from './Directive.js';
12
12
  const ExternalSiteLink_ = ({ name, href = '', className, ...props }) => {
13
13
  const isPrint = useIsPrint();
14
+ const { siteData } = usePageData();
14
15
  const site = useMemo(() => virtual.sites?.find((s) => s.name === name), [name]);
15
16
  const lang = useLang();
16
17
  if (!site) {
@@ -20,7 +21,7 @@ const ExternalSiteLink_ = ({ name, href = '', className, ...props }) => {
20
21
  return _jsxs(Directive, { type: "danger", children: ["Invalid href `", href, "` found"] });
21
22
  }
22
23
  let { url, hash } = parseUrl(href);
23
- const extname = url.split('.').pop();
24
+ const extname = url.split('.').at(-1);
24
25
  if (extname) {
25
26
  if (DEFAULT_PAGE_EXTENSIONS.includes(`.${extname}`)) {
26
27
  url = url.replace(new RegExp(`\\.${extname}$`), '');
@@ -32,7 +33,7 @@ const ExternalSiteLink_ = ({ name, href = '', className, ...props }) => {
32
33
  (isUnversioned(virtual.version)
33
34
  ? site.base
34
35
  : addTrailingSlash(site.base + site.version)) +
35
- (lang ? addTrailingSlash(lang) : '') +
36
+ (lang && lang !== siteData.lang ? addTrailingSlash(lang) : '') +
36
37
  (hash ? `${url}#${hash}` : url), target: "_blank", rel: "noopener noreferrer", className: clsx(classes.link, 'rp-cursor-pointer', className), ...props }));
37
38
  };
38
39
  export const ExternalSiteLink = (props) => (_jsx(NoSSR, { children: _jsx(ExternalSiteLink_, { ...props }) }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alauda/doom",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "type": "module",
5
5
  "description": "Doctor Doom making docs.",
6
6
  "repository": "git+https://github.com/alauda/doom.git",