|
@@ -1,4 +1,4 @@
|
|
|
-import React, { memo } from 'react';
|
|
|
|
|
|
|
+import React, { memo, useCallback } from 'react';
|
|
|
|
|
|
|
|
import Link from 'next/link';
|
|
import Link from 'next/link';
|
|
|
import urljoin from 'url-join';
|
|
import urljoin from 'url-join';
|
|
@@ -19,9 +19,16 @@ type PagePathHierarchicalLinkProps = {
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
|
const PagePathHierarchicalLink = memo((props: PagePathHierarchicalLinkProps): JSX.Element => {
|
|
const PagePathHierarchicalLink = memo((props: PagePathHierarchicalLinkProps): JSX.Element => {
|
|
|
const {
|
|
const {
|
|
|
- linkedPagePath, linkedPagePathByHtml, basePath, isInTrash,
|
|
|
|
|
|
|
+ linkedPagePath, linkedPagePathByHtml, basePath, isInTrash, isInnerElem,
|
|
|
} = props;
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
+ // eslint-disable-next-line react/prop-types
|
|
|
|
|
+ const RootElm = useCallback(({ children }) => {
|
|
|
|
|
+ return isInnerElem
|
|
|
|
|
+ ? <>{children}</>
|
|
|
|
|
+ : <span className="grw-page-path-hierarchical-link text-break">{children}</span>;
|
|
|
|
|
+ }, [isInnerElem]);
|
|
|
|
|
+
|
|
|
// render root element
|
|
// render root element
|
|
|
if (linkedPagePath.isRoot) {
|
|
if (linkedPagePath.isRoot) {
|
|
|
if (basePath != null) {
|
|
if (basePath != null) {
|
|
@@ -30,17 +37,17 @@ const PagePathHierarchicalLink = memo((props: PagePathHierarchicalLinkProps): JS
|
|
|
|
|
|
|
|
return isInTrash
|
|
return isInTrash
|
|
|
? (
|
|
? (
|
|
|
- <>
|
|
|
|
|
|
|
+ <RootElm>
|
|
|
<span className="path-segment">
|
|
<span className="path-segment">
|
|
|
<Link href="/trash" prefetch={false}>
|
|
<Link href="/trash" prefetch={false}>
|
|
|
<a ><i className="icon-trash"></i></a>
|
|
<a ><i className="icon-trash"></i></a>
|
|
|
</Link>
|
|
</Link>
|
|
|
</span>
|
|
</span>
|
|
|
<span className="separator"><a href="/">/</a></span>
|
|
<span className="separator"><a href="/">/</a></span>
|
|
|
- </>
|
|
|
|
|
|
|
+ </RootElm>
|
|
|
)
|
|
)
|
|
|
: (
|
|
: (
|
|
|
- <>
|
|
|
|
|
|
|
+ <RootElm>
|
|
|
<span className="path-segment">
|
|
<span className="path-segment">
|
|
|
<Link href="/" prefetch={false}>
|
|
<Link href="/" prefetch={false}>
|
|
|
<a >
|
|
<a >
|
|
@@ -49,7 +56,7 @@ const PagePathHierarchicalLink = memo((props: PagePathHierarchicalLinkProps): JS
|
|
|
</a>
|
|
</a>
|
|
|
</Link>
|
|
</Link>
|
|
|
</span>
|
|
</span>
|
|
|
- </>
|
|
|
|
|
|
|
+ </RootElm>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -61,13 +68,6 @@ const PagePathHierarchicalLink = memo((props: PagePathHierarchicalLinkProps): JS
|
|
|
|
|
|
|
|
const href = encodeURI(urljoin(basePath || '/', linkedPagePath.href));
|
|
const href = encodeURI(urljoin(basePath || '/', linkedPagePath.href));
|
|
|
|
|
|
|
|
- // eslint-disable-next-line react/prop-types
|
|
|
|
|
- const RootElm = ({ children }) => {
|
|
|
|
|
- return props.isInnerElem
|
|
|
|
|
- ? <>{children}</>
|
|
|
|
|
- : <span className="grw-page-path-hierarchical-link text-break">{children}</span>;
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
return (
|
|
return (
|
|
|
<RootElm>
|
|
<RootElm>
|
|
|
{ isParentExists && (
|
|
{ isParentExists && (
|