Skip to content

Commit

Permalink
fix: article view tag issue #186
Browse files Browse the repository at this point in the history
  • Loading branch information
Blinko committed Nov 27, 2024
1 parent ff53b02 commit 16503a3
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/components/BlinkoCard/blogContent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Image } from '@nextui-org/react';
import { Note } from '@/server/types';
import { helper } from '@/lib/helper';

interface BlogContentProps {
blinkoItem: Note & {
Expand Down Expand Up @@ -30,11 +31,20 @@ export const BlogContent = ({ blinkoItem, isExpanded }: BlogContentProps) => {
{
!!blinkoItem?.tags?.length && blinkoItem?.tags?.length > 0 && (
<div className='flex flex-nowrap gap-1 overflow-x-scroll mt-1 hide-scrollbar'>
{blinkoItem?.tags?.map((tag) => (
<div key={tag.tagId} className='text-desc text-xs blinko-tag whitespace-nowrap'>
#{tag.tag.name}
</div>
))}
{(() => {
const tagTree = helper.buildHashTagTreeFromDb(blinkoItem.tags.map(t => t.tag));
const tagPaths = tagTree.flatMap(node => helper.generateTagPaths(node));
const uniquePaths = tagPaths.filter(path => {
return !tagPaths.some(otherPath =>
otherPath !== path && otherPath.startsWith(path + '/')
);
});
return uniquePaths.map((path) => (
<div key={path} className='text-desc text-xs blinko-tag whitespace-nowrap'>
#{path}
</div>
));
})()}
</div>
)}
</div>
Expand Down

0 comments on commit 16503a3

Please sign in to comment.