generated from mateusfg7/nextjs-setup
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
226 additions
and
1 deletion.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
src/app/about/statistics/components/writing-dashboard/cards/most-used-category.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { | ||
Icon as PhosphorIcon, | ||
FolderOpen, | ||
TextAlignLeft, | ||
CompassTool, | ||
NoteBlank, | ||
ListBullets | ||
} from '@/shared/wrappers/phosphor-icons' | ||
import { allPosts } from 'contentlayer/generated' | ||
|
||
type RowProps = { | ||
Icon: PhosphorIcon | ||
title: string | ||
quantity: number | ||
} | ||
const Row = ({ Icon, quantity, title }: RowProps) => ( | ||
<div className="flex w-full items-center justify-between gap-3"> | ||
<div className="flex items-center gap-3"> | ||
<Icon /> | ||
<span>{title}</span> | ||
</div> | ||
<span>{quantity}</span> | ||
</div> | ||
) | ||
|
||
function getQuantity(category: string) { | ||
return allPosts.filter(post => post.category === category).length | ||
} | ||
|
||
export async function MostUsedCategories() { | ||
const categories = [ | ||
{ | ||
title: 'How To', | ||
icon: CompassTool, | ||
number: getQuantity('How To') | ||
}, | ||
{ | ||
title: 'Article', | ||
icon: TextAlignLeft, | ||
number: getQuantity('Article') | ||
}, | ||
{ | ||
title: 'List', | ||
icon: ListBullets, | ||
number: getQuantity('List') | ||
}, | ||
{ | ||
title: 'Notes', | ||
icon: NoteBlank, | ||
number: getQuantity('Notes') | ||
} | ||
].sort((a, b) => b.number - a.number) | ||
|
||
return ( | ||
<div className="flex h-full w-full flex-col justify-center gap-3 rounded-3xl bg-neutral-200 p-4 leading-none dark:bg-neutral-950 md:p-7"> | ||
<span className="inline-flex items-center gap-2 text-neutral-600"> | ||
<span>Most Used Categories</span> | ||
<FolderOpen weight="duotone" /> | ||
</span> | ||
<div className="flex h-full flex-col justify-around gap-2 text-2xl"> | ||
{categories.map(category => ( | ||
<Row | ||
key={category.title} | ||
Icon={category.icon} | ||
title={category.title} | ||
quantity={category.number} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
) | ||
} |
14 changes: 14 additions & 0 deletions
14
src/app/about/statistics/components/writing-dashboard/cards/posts.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { allPosts } from 'contentlayer/generated' | ||
import { Article } from '@/shared/wrappers/phosphor-icons' | ||
|
||
export async function Posts() { | ||
return ( | ||
<div className="flex h-full w-full flex-col justify-center gap-3 rounded-3xl bg-neutral-200 p-4 leading-none dark:bg-neutral-950 md:p-7"> | ||
<span className="inline-flex items-center gap-2 text-neutral-600"> | ||
<span>Posts</span> | ||
<Article weight="duotone" /> | ||
</span> | ||
<div className="flex h-full items-center text-2xl">{allPosts.length}</div> | ||
</div> | ||
) | ||
} |
92 changes: 92 additions & 0 deletions
92
src/app/about/statistics/components/writing-dashboard/cards/tag-cloud.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
'use client' | ||
|
||
import ReactWordcloud, { Word, Options, defaultOptions } from 'react-wordcloud' | ||
import { Tag } from '@/shared/wrappers/phosphor-icons' | ||
import { getTagsAndNumberOfPosts } from '@/shared/lib/tags' | ||
|
||
export async function TagCloud() { | ||
// const words: Word[] = [ | ||
// { | ||
// text: 'mateus', | ||
// value: 10 | ||
// }, | ||
// { | ||
// text: 'rust', | ||
// value: 10 | ||
// }, | ||
// { | ||
// text: 'deno', | ||
// value: 6 | ||
// }, | ||
// { | ||
// text: 'bun', | ||
// value: 6 | ||
// }, | ||
// { | ||
// text: 'node', | ||
// value: 6 | ||
// }, | ||
// { | ||
// text: 'next.js', | ||
// value: 6 | ||
// }, | ||
// { | ||
// text: 'felipe', | ||
// value: 4 | ||
// }, | ||
// { | ||
// text: 'svelte', | ||
// value: 4 | ||
// }, | ||
// { | ||
// text: 'vue', | ||
// value: 4 | ||
// }, | ||
// { | ||
// text: 'nest.js', | ||
// value: 2 | ||
// }, | ||
// { | ||
// text: 'python', | ||
// value: 2 | ||
// } | ||
// ] | ||
|
||
const words: Word[] = getTagsAndNumberOfPosts().map(value => ({ | ||
text: value.tag, | ||
value: value.numberOfPosts | ||
})) | ||
|
||
return ( | ||
<div className="flex h-min w-full flex-col justify-center gap-3 rounded-3xl bg-neutral-200 p-4 leading-none dark:bg-neutral-950 md:p-7"> | ||
<span className="inline-flex items-center gap-2 text-neutral-600"> | ||
<span>Most Used Tags</span> | ||
<Tag weight="duotone" /> | ||
</span> | ||
<div className="flex items-center text-2xl"> | ||
<div className="dark:hidden"> | ||
<ReactWordcloud | ||
words={words} | ||
options={{ | ||
rotationAngles: [0, 0], | ||
rotations: 0, | ||
padding: 5, | ||
colors: ['#333'] | ||
}} | ||
/> | ||
</div> | ||
<div className="hidden h-full w-full dark:block"> | ||
<ReactWordcloud | ||
words={words} | ||
options={{ | ||
rotationAngles: [0, 0], | ||
rotations: 0, | ||
padding: 5, | ||
colors: ['#666'] | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
14 changes: 14 additions & 0 deletions
14
src/app/about/statistics/components/writing-dashboard/cards/tils.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { allTILs } from 'contentlayer/generated' | ||
import { Notebook } from '@/shared/wrappers/phosphor-icons' | ||
|
||
export async function TILs() { | ||
return ( | ||
<div className="flex h-full w-full flex-col justify-center gap-3 rounded-3xl bg-neutral-200 p-4 leading-none dark:bg-neutral-950 md:p-7"> | ||
<span className="inline-flex items-center gap-2 text-neutral-600"> | ||
<span>TILs</span> | ||
<Notebook weight="duotone" /> | ||
</span> | ||
<div className="flex h-full items-center text-2xl">{allTILs.length}</div> | ||
</div> | ||
) | ||
} |
21 changes: 21 additions & 0 deletions
21
src/app/about/statistics/components/writing-dashboard/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { MostUsedCategories } from './cards/most-used-category' | ||
import { Posts } from './cards/posts' | ||
import { TagCloud } from './cards/tag-cloud' | ||
import { TILs } from './cards/tils' | ||
|
||
export function WritingDashboard() { | ||
return ( | ||
<div className="grid grid-cols-1 gap-3 md:grid-cols-4"> | ||
<Posts /> | ||
<TILs /> | ||
|
||
<div className="col-span-2 row-span-3"> | ||
<TagCloud /> | ||
</div> | ||
|
||
<div className="col-span-2 row-span-2"> | ||
<MostUsedCategories /> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters