|
|
|
@@ -26,13 +26,13 @@ import { dateString, originalCreatedAtString } from '@/lib/utils' |
|
|
|
import type { DragEndEvent } from '@dnd-kit/core' |
|
|
|
import type { FC, MutableRefObject, ReactNode } from 'react' |
|
|
|
|
|
|
|
import type { Category, Post, Tag } from '@/types' |
|
|
|
import type { Category, Post, TagWithSections } from '@/types' |
|
|
|
|
|
|
|
type TagByCategory = { [key in Category]: Tag[] } |
|
|
|
type TagByCategory = { [key in Category]: TagWithSections[] } |
|
|
|
|
|
|
|
|
|
|
|
const renderTagTree = ( |
|
|
|
tag: Tag, |
|
|
|
tag: TagWithSections, |
|
|
|
nestLevel: number, |
|
|
|
path: string, |
|
|
|
suppressClickRef: MutableRefObject<boolean>, |
|
|
|
@@ -63,7 +63,7 @@ const renderTagTree = ( |
|
|
|
|
|
|
|
|
|
|
|
const isDescendant = ( |
|
|
|
root: Tag, |
|
|
|
root: TagWithSections, |
|
|
|
targetId: number, |
|
|
|
): boolean => { |
|
|
|
if (!(root.children)) |
|
|
|
@@ -84,8 +84,8 @@ const isDescendant = ( |
|
|
|
const findTag = ( |
|
|
|
byCat: TagByCategory, |
|
|
|
id: number, |
|
|
|
): Tag | undefined => { |
|
|
|
const walk = (nodes: Tag[]): Tag | undefined => { |
|
|
|
): TagWithSections | undefined => { |
|
|
|
const walk = (nodes: TagWithSections[]): TagWithSections | undefined => { |
|
|
|
for (const t of nodes) |
|
|
|
{ |
|
|
|
if (t.id === id) |
|
|
|
@@ -167,7 +167,7 @@ const TagDetailSidebar: FC<Props> = ({ post, sp }) => { |
|
|
|
} |
|
|
|
|
|
|
|
for (const cat of Object.keys (tagsTmp) as (keyof typeof tagsTmp)[]) |
|
|
|
tagsTmp[cat].sort ((tagA: Tag, tagB: Tag) => tagA.name < tagB.name ? -1 : 1) |
|
|
|
tagsTmp[cat].sort ((tagA: TagWithSections, tagB: TagWithSections) => tagA.name < tagB.name ? -1 : 1) |
|
|
|
|
|
|
|
return tagsTmp |
|
|
|
}, [post]) |
|
|
|
@@ -378,4 +378,4 @@ const TagDetailSidebar: FC<Props> = ({ post, sp }) => { |
|
|
|
</SidebarComponent>) |
|
|
|
} |
|
|
|
|
|
|
|
export default TagDetailSidebar |
|
|
|
export default TagDetailSidebar |