-
Notifications
You must be signed in to change notification settings - Fork 22
[Feature] Blog Category #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
efca4b0
feature_category
sunzhongkai588 5375fcb
fix style
sunzhongkai588 ab2da86
Merge branch 'main' of https://github.com/PFCCLab/blog into category_
sunzhongkai588 96a90a4
fix url page
sunzhongkai588 70ec363
fix style
sunzhongkai588 0dda87a
Merge branch 'main' of https://github.com/PFCCLab/blog into category_
sunzhongkai588 b68ad5a
fix
sunzhongkai588 d6984b0
fix codestyle
sunzhongkai588 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,35 @@ | ||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
|
||
const props = defineProps<{ | ||
activeCategory: string | ||
onChange: (category: string) => void | ||
}>() | ||
|
||
const categories = [ | ||
{ id: 'all', name: 'ALL' }, | ||
{ id: 'community-activity', name: '飞桨开源社区动态' }, | ||
{ id: 'developer-story', name: '飞桨社区开发者访谈' }, | ||
{ id: 'insights', name: '前沿洞察' }, | ||
] | ||
</script> | ||
|
||
<template> | ||
<div class="blog-categories mb-8"> | ||
<div class="flex flex-wrap gap-2"> | ||
<button | ||
v-for="category in categories" | ||
:key="category.id" | ||
:class="[ | ||
'px-4 py-2 rounded-full text-sm font-medium transition-colors', | ||
activeCategory === category.id | ||
? 'bg-blue-600 text-white' | ||
: 'bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200 hover:bg-gray-200 dark:hover:bg-gray-700', | ||
]" | ||
@click="onChange(category.id)" | ||
> | ||
{{ category.name }} | ||
</button> | ||
</div> | ||
</div> | ||
</template> |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,38 @@ | ||
/** | ||
* 从URL获取当前分类参数 | ||
* @returns {string|null} 分类参数值或null | ||
*/ | ||
export function getCurrentCategory() { | ||
const urlParams = new URLSearchParams(window.location.search) | ||
return urlParams.get('category') | ||
} | ||
|
||
/** | ||
* 更新URL中的分类参数但不刷新页面 | ||
* @param {string} category 分类名称 | ||
*/ | ||
export function updateCategoryInUrl(category) { | ||
const url = new URL(window.location.href) | ||
|
||
if (category === 'all') { | ||
// 如果选择"all",则移除category参数 | ||
url.searchParams.delete('category') | ||
} else { | ||
// 否则设置category参数 | ||
url.searchParams.set('category', category) | ||
} | ||
|
||
window.history.pushState({}, '', url) | ||
} | ||
|
||
/** | ||
* 导航到指定分类的首页 | ||
* @param {string} category 分类名称 | ||
*/ | ||
export function navigateToCategory(category) { | ||
if (category === 'all') { | ||
window.location.href = '/' | ||
} else { | ||
window.location.href = `/?category=${category}` | ||
} | ||
} |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
|
@@ -4,6 +4,7 @@ date: 2024-11-27 | |
author: | ||
name: 小莹莹 | ||
github: E-Pudding | ||
category: community-activity | ||
--- | ||
|
||
<style> | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -4,6 +4,7 @@ date: 2024-11-17 | |
author: | ||
name: 小莹莹 | ||
github: E-Pudding | ||
category: community-activity | ||
--- | ||
|
||
<style> | ||
|
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有什么用吗?删掉也没什么影响
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那删了