|
|
@@ -6,8 +6,8 @@ import { isPopulated, type IPageHasId } from '@growi/core';
|
|
|
import { DevidedPagePath } from '@growi/core/dist/models';
|
|
|
import { UserPicture, FootstampIcon } from '@growi/ui/dist/components';
|
|
|
import { useTranslation } from 'next-i18next';
|
|
|
-import Link from 'next/link';
|
|
|
|
|
|
+import { useKeywordManager } from '~/client/services/search-operation';
|
|
|
import PagePathHierarchicalLink from '~/components/PagePathHierarchicalLink';
|
|
|
import LinkedPagePath from '~/models/linked-page-path';
|
|
|
import { useSWRINFxRecentlyUpdated } from '~/stores/page-listing';
|
|
|
@@ -30,6 +30,7 @@ type PageItemLowerProps = {
|
|
|
|
|
|
type PageItemProps = PageItemLowerProps & {
|
|
|
isSmall: boolean
|
|
|
+ onClickTag?: (tagName: string) => void,
|
|
|
}
|
|
|
|
|
|
const PageItemLower = memo(({ page }: PageItemLowerProps): JSX.Element => {
|
|
|
@@ -49,7 +50,7 @@ const PageItemLower = memo(({ page }: PageItemLowerProps): JSX.Element => {
|
|
|
});
|
|
|
PageItemLower.displayName = 'PageItemLower';
|
|
|
|
|
|
-const PageItem = memo(({ page, isSmall }: PageItemProps): JSX.Element => {
|
|
|
+const PageItem = memo(({ page, isSmall, onClickTag }: PageItemProps): JSX.Element => {
|
|
|
const dPagePath = new DevidedPagePath(page.path, false, true);
|
|
|
const linkedPagePathFormer = new LinkedPagePath(dPagePath.former);
|
|
|
const linkedPagePathLatter = new LinkedPagePath(dPagePath.latter);
|
|
|
@@ -70,14 +71,14 @@ const PageItem = memo(({ page, isSmall }: PageItemProps): JSX.Element => {
|
|
|
return <></>;
|
|
|
}
|
|
|
return (
|
|
|
- <Link
|
|
|
+ <a
|
|
|
key={tag.name}
|
|
|
- href={`/_search?q=tag:${tag.name}`}
|
|
|
+ type="button"
|
|
|
className="grw-tag-label badge badge-secondary mr-2 small"
|
|
|
- prefetch={false}
|
|
|
+ onClick={() => onClickTag?.(tag.name)}
|
|
|
>
|
|
|
{tag.name}
|
|
|
- </Link>
|
|
|
+ </a>
|
|
|
);
|
|
|
});
|
|
|
|
|
|
@@ -113,6 +114,8 @@ const RecentChanges = (): JSX.Element => {
|
|
|
data, mutate, isLoading,
|
|
|
} = swrInifinitexRecentlyUpdated;
|
|
|
|
|
|
+ const { pushState } = useKeywordManager();
|
|
|
+
|
|
|
const [isRecentChangesSidebarSmall, setIsRecentChangesSidebarSmall] = useState(false);
|
|
|
const isEmpty = data?.[0]?.pages.length === 0;
|
|
|
const isReachingEnd = isEmpty || (data != null && data[data.length - 1]?.pages.length < PER_PAGE);
|
|
|
@@ -162,7 +165,7 @@ const RecentChanges = (): JSX.Element => {
|
|
|
>
|
|
|
{ data != null && data.map(apiResult => apiResult.pages).flat()
|
|
|
.map(page => (
|
|
|
- <PageItem key={page._id} page={page} isSmall={isRecentChangesSidebarSmall} />
|
|
|
+ <PageItem key={page._id} page={page} isSmall={isRecentChangesSidebarSmall} onClickTag={tagName => pushState(`tag:${tagName}`)} />
|
|
|
))
|
|
|
}
|
|
|
</InfiniteScroll>
|