Skip to content

Commit

Permalink
perf: finish embed, tags page
Browse files Browse the repository at this point in the history
  • Loading branch information
521xueweihan committed Jul 19, 2024
1 parent 7b826fd commit 855dd3b
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 81 deletions.
47 changes: 47 additions & 0 deletions public/locales/en/claim.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"title": "Wear HelloGitHub Badge",
"description": "Showcase the honor of your open-source project and help promote and operate it",
"navbar": "HelloGitHub Badge",
"top_h2": "Join the HelloGitHub Badge Program",
"top_text": "This is a program to claim open-source projects. After claiming, you can wear the HelloGitHub badge to show the world the community recognition and recommendation your project has received, <strong>showcasing the honor of your open-source project</strong>. At the same time, <strong>claim your open-source project</strong> to enjoy more recommendations and benefits brought by the community.",
"badge_theme_neutral": "Neutral",
"badge_theme_dark": "Dark",
"badge_theme_small": "Minimal",
"copy": {
"text": "Copy Code",
"success": "Copy Success",
"warning": "Badge is being generated, please try again later",
"fail": "Copy Failed"
},
"submit": {
"text": "Submit",
"loding": "Submitting",
"check_fail": "Please enter the correct README filename!",
"check_fail2": "This project has not been included yet, please submit the project first.",
"check_fail3": "This repository has already been claimed!",
"success": "Congratulations! Your submission was successful. Please wait for community confirmation.",
"fail": "Authentication failed! Please check the README filename and code integrity.",
"fail2": "Authentication failed! Please check the network and README filename."
},
"rights": {
"item1": "<strong>Community Recognition:</strong> The badge represents that your project has passed the strict screening of the HelloGitHub community and has been recommended.",
"item2": "<strong>Increased Exposure:</strong> Completing the claim (wearing the badge) will get more recommendation traffic, attracting potential users and contributors.",
"item3": "<strong>Interaction Opportunities:</strong> Users can quickly understand the project through the badge, and enhance community interaction through likes, comments, and collections.",
"item4": "<strong>Feedback Accumulation:</strong> Collect real feedback from a wide range of users to continuously optimize your project.",
"item5": "<strong>Author Identification:</strong> After authentication, comments you post will show a prominent identifier and will be pinned to the top."
},
"howto": {
"title": "How to Claim an Open Source Project",
"step1": "Confirm that your project has been included by the HelloGitHub community, click",
"step2": "Find a suitable position in the README file of your project, <strong>paste</strong> the copied code, and submit the change.",
"step3": "After wearing the badge, enter your project's README filename:",
"step4": "After being approved by the HelloGitHub team, your project will enjoy more recommendations and benefits."
},
"question": {
"title": "Frequently Asked Questions",
"item1": "<strong>Authentication Rights:</strong> Only the author of the project or contributors with modification rights can authenticate. Please make sure you have sufficient rights to claim.",
"item2": "<strong>Authentication Failed:</strong> Only projects included by the community are eligible. If your project has not been included, please submit your project first.",
"item3": "<strong>Each project can only be claimed once:</strong> After authentication, the claimer of the project cannot be modified. Please check all information carefully before operation.",
"item4": "<strong>Need Help:</strong> You can contact me via Email: [email protected]."
}
}
14 changes: 7 additions & 7 deletions public/locales/en/repository.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@
"reply": "Reply",
"cancel": "Cancel",
"item": {
"featured": "Featured",
"unfeatured": "Not Featured",
"vote": "Vote",
"expand": "Expand",
"collapse": "Collapse",
"login": "Please log in first"
},
"featured": "Featured",
"unfeatured": "Not Featured",
"vote": "Vote",
"expand": "Expand",
"collapse": "Collapse",
"login": "Please log in first"
},
"submit": {
"reply_placeholder": "Reply to: {{nickname}}",
"placeholder": "Write your experience, opinions, usages, or anything special about this project...",
Expand Down
11 changes: 5 additions & 6 deletions public/locales/en/topic.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"title": "Open Source Projects with the {{name}} Topic",
"description": "Interesting and Fun Open Source Projects with the {{name}} Topic",
"navbar": "Topic",
"bottom_text": "That's all for now, only these are available at the moment"
}

"title": "Open Source Projects with the {{name}} Topic",
"description": "Interesting and Fun Open Source Projects with the {{name}} Topic",
"navbar": "Topic",
"bottom_text": "That's all for now, only these are available at the moment"
}
48 changes: 48 additions & 0 deletions public/locales/zh/claim.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"title": "佩戴 HelloGitHub 徽章",
"description": "彰显开源项目荣耀,帮助推广和运营开源项目",
"navbar": "HelloGitHub 徽章",
"top_h2": "加入 HelloGitHub 徽章计划",
"top_text": "这是一个开源项目的认领计划,认领后通过佩戴 HelloGitHub 徽章,向世界展示项目得到的社区认可和推荐,<strong>彰显开源项目荣耀</strong>。同时,<strong>认领你的开源项目</strong>,享受社区带来的更多推荐和权益。",
"badge_theme_neutral": "普通",
"badge_theme_dark": "黑暗",
"badge_theme_small": "极简",
"copy": {
"text": "复制代码",
"success": "复制成功",
"warning": "徽章生成中,请稍后重试",
"fail": "复制失败"
},
"submit": {
"text": "提交",
"loding": "正在提交",
"check_fail": "请输入正确的 README 文件名!",
"check_fail2": "该项目还未被收录,请先提交项目",
"check_fail3": "该仓库已被认领!",

"success": "恭喜你!已提交成功,请等待社区确认",
"fail": "认证失败!请确认 README 文件名和代码完整性",
"fail2": "认证失败!请检查网络和 README 文件名"
},
"rights": {
"item1": "<strong>社区认可:</strong>徽章代表你的项目已通过 HelloGitHub 社区的严格筛选,并获得推荐。",
"item2": "<strong>增加曝光:</strong>完成认领(佩戴徽章)将获得更多推荐流量,吸引潜在用户和贡献者的目光。",
"item3": "<strong>互动机会:</strong>用户可通过徽章快速了解项目,并通过点赞、评论、收藏,增强社区互动。",
"item4": "<strong>反馈积累:</strong>收集来自广大用户的真实反馈,持续优化你的项目。",
"item5": "<strong>作者标识:</strong>认证后发布评论将显示醒目的标识,并获得评论置顶。"
},
"howto": {
"title": "如何认领开源项目",
"step1": "确认您的项目已被 HelloGitHub 社区收录,点击",
"step2": "在您项目 README 文件中找到合适的位置,<strong>粘贴</strong>已复制的代码,并提交更改。",
"step3": "完成徽章佩戴后,输入您的项目 README 文件名:",
"step4": "HelloGitHub 团队审核通过后,您的项目将享受更多推荐和权益。"
},
"question": {
"title": "常见问题",
"item1": "<strong>认证权限:</strong>仅限于项目的作者或拥有修改权限的贡献者,请确保您有足够的权限进行认领。",
"item2": "<strong>认证失败:</strong>仅限社区已收录的项目。如果您的项目尚未被收录,请先提交您的项目。",
"item3": "<strong>每个项目只能认领一次:</strong> 认证后项目的认领者不可修改。请在操作前仔细检查所有信息。",
"item4": "<strong>需要帮助:</strong>可通过微信联系我:xueweihan(备注:认领)。"
}
}
11 changes: 5 additions & 6 deletions public/locales/zh/topic.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"title": "{{name}} 标签的开源项目",
"description": "有趣、好玩的 {{name}} 开源项目",
"navbar": "标签",
"bottom_text": "到底了,目前只开放了这些"

}
"title": "{{name}} 标签的开源项目",
"description": "有趣、好玩的 {{name}} 开源项目",
"navbar": "标签",
"bottom_text": "到底了,目前只开放了这些"
}
5 changes: 3 additions & 2 deletions src/components/navbar/IndexBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import TagLink from '@/components/links/TagLink';

type Props = {
t: (key: string) => string;
i18n_lang: string;
tid: string;
sort_by: string;
};

const IndexBar: NextPage<Props> = ({ t, tid, sort_by }) => {
const IndexBar: NextPage<Props> = ({ t, i18n_lang, tid, sort_by }) => {
const { labelStatus, tagItems, featuredURL, allURL, handleTagButton } =
useTagHandling(tid, sort_by);
useTagHandling(tid, sort_by, i18n_lang);

const linkClassName = (sortName: string) =>
classNames(
Expand Down
18 changes: 13 additions & 5 deletions src/hooks/useTagHandling.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,30 @@ import { isMobile } from '@/utils/util';

import { Tag } from '@/types/tag';

const useTagHandling = (tid: string, sort_by: string) => {
const useTagHandling = (tid: string, sort_by: string, i18n_lang: string) => {
const router = useRouter();
const [labelStatus, setLabelStatus] = useState(false);
const [tagItems, setTagItems] = useState<Tag[]>([]);
const [featuredURL, setFeaturedURL] = useState<string>('/?sort_by=featured');
const [allURL, setAllURL] = useState<string>('/?sort_by=all');

const handleTags = useCallback(async () => {
const defaultTag = {
name: '综合',
tid: '',
icon_name: 'find',
name_en: 'All',
};
try {
if (tagItems.length === 0) {
const data = await getTags('rank');
if (data?.data) {
data.data.unshift({
name: 'All',
tid: '',
icon_name: '',
data.data.unshift(defaultTag);
// 判断当前语言是否为英文,如果是英文则显示英文名称
data.data.forEach((item) => {
if (i18n_lang == 'en' && item.name_en !== null) {
item.name = item.name_en;
}
});
setTagItems(data.data);
}
Expand Down
7 changes: 6 additions & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ const Index: NextPage = () => {
return (
<>
<Seo title={t('title')} description={t('description')} />
<IndexBar tid={tid as string} sort_by={sort_by as string} t={t} />
<IndexBar
tid={tid as string}
sort_by={sort_by as string}
t={t}
i18n_lang={i18n.language}
/>
<div className='h-screen'>
<Items repositories={repositories} i18n_lang={i18n.language} />
<div
Expand Down
Loading

0 comments on commit 855dd3b

Please sign in to comment.