Skip to content

Commit

Permalink
refactor(data): rename file name
Browse files Browse the repository at this point in the history
  • Loading branch information
kuizuo committed Jan 3, 2024
1 parent 8f23e24 commit 009ee8a
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 64 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion data/resource.ts → data/resources.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Friends } from './friend'
import { Friends } from './friends'

export interface Resource {
name: string
Expand Down
2 changes: 1 addition & 1 deletion data/social.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const social: Social = {
twitter: 'https://twitter.com/kuizuo',
juejin: 'https://juejin.cn/user/1565318510545901',
csdn: 'https://blog.csdn.net/kuizuo12',
qq: 'https://wpa.qq.com/msgrd?v=3&uin=911993023&site=qq',
qq: 'https://img.kuizuo.cn/qq.png',
wx: 'https://img.kuizuo.cn/wechat.png',
// zhihu: 'https://www.zhihu.com/people/kuizuo',
// cloudmusic: 'https://music.163.com/#/user/home?id=1333010742',
Expand Down
2 changes: 1 addition & 1 deletion src/components/UserCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useThemeConfig } from '@docusaurus/theme-common'
import useBaseUrl from '@docusaurus/useBaseUrl'
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'

import { projects } from '@site/data/project'
import { projects } from '@site/data/projects'

import styles from './styles.module.scss'

Expand Down
2 changes: 1 addition & 1 deletion src/pages/_components/ProjectSection/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useLayoutEffect, useRef } from 'react'
import clsx from 'clsx'
import { Project, projects } from '@site/data/project'
import { Project, projects } from '@site/data/projects'
import Translate from '@docusaurus/Translate'
import styles from './styles.module.scss'
import {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/friends/_components/FriendCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import clsx from 'clsx'
import Link from '@docusaurus/Link'

import styles from './styles.module.css'
import { type Friend } from '@site/data/friend'
import { type Friend } from '@site/data/friends'

const FriendCard = memo(({ friend }: { friend: Friend }) => (
<li className={clsx(styles.friendCard, 'padding-vert--sm padding-horiz--md')}>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/friends/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Layout from '@theme/Layout'
import CodeBlock from '@theme/CodeBlock'

import FriendCard from './_components/FriendCard'
import { Friends } from '@site/data/friend'
import { Friends } from '@site/data/friends'

import styles from './styles.module.css'
import { motion } from 'framer-motion'
Expand Down
49 changes: 12 additions & 37 deletions src/pages/project/_components/ShowcaseCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,29 @@ import Translate from '@docusaurus/Translate'
import styles from './styles.module.css'
import FavoriteIcon from '@site/src/components/svgIcons/FavoriteIcon'
import Tooltip from '../ShowcaseTooltip'
import {
Tags,
TagList,
type TagType,
type Project,
type Tag,
} from '@site/data/project'
import { Tags, TagList, type TagType, type Project, type Tag } from '@site/data/projects'
import { sortBy } from '@site/src/utils/jsUtils'

const TagComp = React.forwardRef<HTMLLIElement, Tag>(
({ label, color, description }, ref) => (
<li ref={ref} className={styles.tag} title={description}>
<span className={styles.textLabel}>{label.toLowerCase()}</span>
<span className={styles.colorLabel} style={{ backgroundColor: color }} />
</li>
),
)
const TagComp = React.forwardRef<HTMLLIElement, Tag>(({ label, color, description }, ref) => (
<li ref={ref} className={styles.tag} title={description}>
<span className={styles.textLabel}>{label.toLowerCase()}</span>
<span className={styles.colorLabel} style={{ backgroundColor: color }} />
</li>
))

function ShowcaseCardTag({ tags }: { tags: TagType[] }) {
const tagObjects = tags.map(tag => ({ tag, ...Tags[tag] }))

// Keep same order for all tags
const tagObjectsSorted = sortBy(tagObjects, tagObject =>
TagList.indexOf(tagObject.tag),
)
const tagObjectsSorted = sortBy(tagObjects, tagObject => TagList.indexOf(tagObject.tag))

return (
<>
{tagObjectsSorted.map((tagObject, index) => {
const id = `showcase_card_tag_${tagObject.tag}`

return (
<Tooltip
key={index}
text={tagObject.description}
anchorEl="#__docusaurus"
id={id}
>
<Tooltip key={index} text={tagObject.description} anchorEl="#__docusaurus" id={id}>
<TagComp key={index} {...tagObject} />
</Tooltip>
)
Expand All @@ -54,17 +39,10 @@ function ShowcaseCardTag({ tags }: { tags: TagType[] }) {

const ShowcaseCard = memo(({ project }: { project: Project }) => {
return (
<div
key={project.title}
className={clsx('card', styles.showcaseCard)}
>
<div key={project.title} className={clsx('card', styles.showcaseCard)}>
{project.preview && (
<div className={clsx('card__image', styles.showcaseCardImage)}>
<Image
src={project.preview}
alt={project.title}
img={project.preview}
/>
<Image src={project.preview} alt={project.title} img={project.preview} />
</div>
)}
<div className="card__body">
Expand All @@ -80,10 +58,7 @@ const ShowcaseCard = memo(({ project }: { project: Project }) => {
{project.source && (
<Link
href={project.source}
className={clsx(
'button button--secondary button--sm',
styles.showcaseCardSrcBtn,
)}
className={clsx('button button--secondary button--sm', styles.showcaseCardSrcBtn)}
>
<Translate id="showcase.card.sourceLink">源码</Translate>
</Link>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/project/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import clsx from 'clsx'
import { translate } from '@docusaurus/Translate'
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'
import ShowcaseCard from './_components/ShowcaseCard'
import { projects, groupByProjects, projectTypeMap } from '@site/data/project'
import { projects, groupByProjects, projectTypeMap } from '@site/data/projects'

import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment'

Expand Down Expand Up @@ -79,7 +79,7 @@ function ShowcaseCards() {
return (
<div key={key}>
<div className={clsx('margin-bottom--md', styles.showcaseFavoriteHeader)}>
<h3>{_.upperFirst(lang === 'en' ? key: projectTypeMap[key])}</h3>
<h3>{_.upperFirst(lang === 'en' ? key : projectTypeMap[key])}</h3>
</div>
<ul className={styles.showcaseList}>
{value.map(project => (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/resource/_components/ResourceCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import clsx from 'clsx'
import Link from '@docusaurus/Link'

import styles from './styles.module.css'
import { type Resource } from '@site/data/resource'
import { type Resource } from '@site/data/resources'
import Tooltip from '../../../project/_components/ShowcaseTooltip'

const ResourceCard = memo(({ resource }: { resource: Resource }) => (
Expand Down
23 changes: 5 additions & 18 deletions src/pages/resource/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import React from 'react'
import clsx from 'clsx'
import Link from '@docusaurus/Link'
import {
PageMetadata,
HtmlClassNameProvider,
ThemeClassNames,
} from '@docusaurus/theme-common'
import { PageMetadata, HtmlClassNameProvider, ThemeClassNames } from '@docusaurus/theme-common'
import Layout from '@theme/Layout'
import ResourceCard from './_components/ResourceCard'
import BackToTopButton from '@theme/BackToTopButton'
import { resourceData } from '@site/data/resource'
import { resourceData } from '@site/data/resources'
import styles from './resource.module.css'

function CategorySidebar() {
Expand All @@ -20,9 +16,7 @@ function CategorySidebar() {

return (
<nav className={clsx(styles.sidebar, 'thin-scrollbar')}>
<div className={clsx(styles.sidebarItemTitle, 'margin-bottom--md')}>
{sidebar.title}
</div>
<div className={clsx(styles.sidebarItemTitle, 'margin-bottom--md')}>{sidebar.title}</div>
<ul className={clsx(styles.sidebarItemList, 'clean-list')}>
{sidebar.items.map(item => (
<li key={item.permalink} className={styles.sidebarItem}>
Expand All @@ -49,11 +43,7 @@ function CategoryList() {
<div className={styles.cateHeader}>
<h2 id={cate.name} className="anchor">
{cate.name}
<a
className="hash-link"
href={`#${cate.name}`}
title={cate.name}
></a>
<a className="hash-link" href={`#${cate.name}`} title={cate.name}></a>
</h2>
</div>
<section>
Expand All @@ -75,10 +65,7 @@ export default function Resources() {

return (
<HtmlClassNameProvider
className={clsx(
ThemeClassNames.wrapper.blogPages,
ThemeClassNames.page.blogTagsListPage,
)}
className={clsx(ThemeClassNames.wrapper.blogPages, ThemeClassNames.page.blogTagsListPage)}
>
<PageMetadata title={title} description={description} />
<Layout>
Expand Down

0 comments on commit 009ee8a

Please sign in to comment.