Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop-astro-nacos' into deve…
Browse files Browse the repository at this point in the history
…lop-astro-nacos
  • Loading branch information
Tinie13 committed May 6, 2024
2 parents d7a70d5 + 560a51d commit 13cc4c5
Show file tree
Hide file tree
Showing 24 changed files with 471 additions and 999 deletions.
Binary file modified public/img/contributors/KeRan213539.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/img/contributors/horizonzy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/img/contributors/zhaoyuguang.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/img/contributors/zongtanghu.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 28 additions & 2 deletions src/components/common/Button.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
interface Props {
href?: string;
type?: "primary" | "normal";
type?: "primary" | "normal" | "active" | "card";
size?: "small" | "medium" | "large";
class?: string;
// hover时是否显示默认的箭头
Expand All @@ -24,7 +24,7 @@ const {
<a
href={href}
target={target}
class=`${type === 'normal' ? 'button-normal' : 'button-primary'} flex items-center justify-center no-underline ${size === 'small' ? 'xp-small h-small' : ''} ${size === 'medium' ? 'xp-medium h-medium' : ''} ${size === 'large' ? 'xp-large h-large' : ''} ${Astro.props?.class || ''}`
class=`button-${type || 'normal'} flex items-center justify-center no-underline ${size === 'small' ? 'xp-small h-small' : ''} ${size === 'medium' ? 'xp-medium h-medium' : ''} ${size === 'large' ? 'xp-large h-large' : ''} ${Astro.props?.class || ''}`
>
<slot />
{
Expand Down Expand Up @@ -65,6 +65,14 @@ const {
--primary-bg-color: theme("colors.gray.13");
--primary-hover-color: theme("colors.gray.12");
--primary-text-color: theme("colors.gray.06");
/* active */
--active-bg-color: theme("colors.blue.08");
--active-hover-color: theme("colors.blue.07");
--active-text-color: theme("colors.gray.03");
/* card */
--card-bg-color: theme("colors.gray.02");
--card-hover-color: theme("colors.gray.03");
--card-text-color: theme("colors.gray.13");

--button-rounded: 0.5rem;

Expand Down Expand Up @@ -110,7 +118,25 @@ const {
}
}

.button-card {
color: var(--card-text-color);
background-color: var(--card-bg-color);
&:hover {
background-color: var(--card-hover-color);
}
}

.button-active {
color: var(--active-text-color);
background-color: var(--active-bg-color);
&:hover {
background-color: var(--active-hover-color);
}
}

.button-normal,
.button-card,
.button-active,
.button-primary {
.icon {
opacity: 0;
Expand Down
2 changes: 1 addition & 1 deletion src/components/contributors/gitHubData.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"login":"nkorange","avatar_url":"https://avatars.githubusercontent.com/u/4593375?v=4","html_url":"https://github.com/nkorange"},{"login":"KomachiSion","avatar_url":"https://avatars.githubusercontent.com/u/37170243?v=4","html_url":"https://github.com/KomachiSion"},{"login":"chuntaojun","avatar_url":"https://avatars.githubusercontent.com/u/23445172?v=4","html_url":"https://github.com/chuntaojun"},{"login":"loadchange","avatar_url":"https://avatars.githubusercontent.com/u/10842824?v=4","html_url":"https://github.com/loadchange"},{"login":"yanlinly","avatar_url":"https://avatars.githubusercontent.com/u/17695352?v=4","html_url":"https://github.com/yanlinly"},{"login":"xuechaos","avatar_url":"https://avatars.githubusercontent.com/u/3983999?v=4","html_url":"https://github.com/xuechaos"},{"login":"jameslcj","avatar_url":"https://avatars.githubusercontent.com/u/11494059?v=4","html_url":"https://github.com/jameslcj"},{"login":"li-xiao-shuang","avatar_url":"https://avatars.githubusercontent.com/u/34903552?v=4","html_url":"https://github.com/li-xiao-shuang"},{"login":"KeRan213539","avatar_url":"https://avatars.githubusercontent.com/u/1195743?v=4","html_url":"https://github.com/KeRan213539"},{"login":"hxy1991","avatar_url":"https://avatars.githubusercontent.com/u/2517258?v=4","html_url":"https://github.com/hxy1991"},{"login":"shiyiyue1102","avatar_url":"https://avatars.githubusercontent.com/u/20452676?v=4","html_url":"https://github.com/shiyiyue1102"},{"login":"brotherlu-xcq","avatar_url":"https://avatars.githubusercontent.com/u/25661357?v=4","html_url":"https://github.com/brotherlu-xcq"},{"login":"horizonzy","avatar_url":"https://avatars.githubusercontent.com/u/22524871?v=4","html_url":"https://github.com/horizonzy"},{"login":"Daydreamer-ia","avatar_url":"https://avatars.githubusercontent.com/u/83362909?v=4","html_url":"https://github.com/Daydreamer-ia"},{"login":"Maijh97","avatar_url":"https://avatars.githubusercontent.com/u/37288946?v=4","html_url":"https://github.com/Maijh97"},{"login":"onewe","avatar_url":"https://avatars.githubusercontent.com/u/38708836?v=4","html_url":"https://github.com/onewe"},{"login":"hujun-w-2","avatar_url":"https://avatars.githubusercontent.com/u/39894911?v=4","html_url":"https://github.com/hujun-w-2"},{"login":"MajorHe1","avatar_url":"https://avatars.githubusercontent.com/u/53824889?v=4","html_url":"https://github.com/MajorHe1"},{"login":"pbting","avatar_url":"https://avatars.githubusercontent.com/u/11469671?v=4","html_url":"https://github.com/pbting"},{"login":"zhaoyuguang","avatar_url":"https://avatars.githubusercontent.com/u/10150229?v=4","html_url":"https://github.com/zhaoyuguang"},{"login":"zongtanghu","avatar_url":"https://avatars.githubusercontent.com/u/5010883?v=4","html_url":"https://github.com/zongtanghu"},{"login":"IanCao","avatar_url":"https://avatars.githubusercontent.com/u/32847163?v=4","html_url":"https://github.com/IanCao"},{"login":"mercyblitz","avatar_url":"https://avatars.githubusercontent.com/u/533114?v=4","html_url":"https://github.com/mercyblitz"},{"login":"ZZQ001010","avatar_url":"https://avatars.githubusercontent.com/u/33930711?v=4","html_url":"https://github.com/ZZQ001010"}]
[{"login":"nkorange","avatar_url":"https://avatars.githubusercontent.com/u/4593375?v=4","html_url":"https://github.com/nkorange"},{"login":"KomachiSion","avatar_url":"https://avatars.githubusercontent.com/u/37170243?v=4","html_url":"https://github.com/KomachiSion"},{"login":"chuntaojun","avatar_url":"https://avatars.githubusercontent.com/u/23445172?v=4","html_url":"https://github.com/chuntaojun"},{"login":"loadchange","avatar_url":"https://avatars.githubusercontent.com/u/10842824?v=4","html_url":"https://github.com/loadchange"},{"login":"yanlinly","avatar_url":"https://avatars.githubusercontent.com/u/17695352?v=4","html_url":"https://github.com/yanlinly"},{"login":"xuechaos","avatar_url":"https://avatars.githubusercontent.com/u/3983999?v=4","html_url":"https://github.com/xuechaos"},{"login":"jameslcj","avatar_url":"https://avatars.githubusercontent.com/u/11494059?v=4","html_url":"https://github.com/jameslcj"},{"login":"li-xiao-shuang","avatar_url":"https://avatars.githubusercontent.com/u/34903552?v=4","html_url":"https://github.com/li-xiao-shuang"},{"login":"KeRan213539","avatar_url":"https://avatars.githubusercontent.com/u/1195743?v=4","html_url":"https://github.com/KeRan213539"},{"login":"hxy1991","avatar_url":"https://avatars.githubusercontent.com/u/2517258?v=4","html_url":"https://github.com/hxy1991"},{"login":"shiyiyue1102","avatar_url":"https://avatars.githubusercontent.com/u/20452676?v=4","html_url":"https://github.com/shiyiyue1102"},{"login":"brotherlu-xcq","avatar_url":"https://avatars.githubusercontent.com/u/25661357?v=4","html_url":"https://github.com/brotherlu-xcq"},{"login":"horizonzy","avatar_url":"https://avatars.githubusercontent.com/u/22524871?v=4","html_url":"https://github.com/horizonzy"},{"login":"Daydreamer-ia","avatar_url":"https://avatars.githubusercontent.com/u/83362909?v=4","html_url":"https://github.com/Daydreamer-ia"},{"login":"Maijh97","avatar_url":"https://avatars.githubusercontent.com/u/37288946?v=4","html_url":"https://github.com/Maijh97"},{"login":"onewe","avatar_url":"https://avatars.githubusercontent.com/u/38708836?v=4","html_url":"https://github.com/onewe"},{"login":"hujun-w-2","avatar_url":"https://avatars.githubusercontent.com/u/39894911?v=4","html_url":"https://github.com/hujun-w-2"},{"login":"MajorHe1","avatar_url":"https://avatars.githubusercontent.com/u/53824889?v=4","html_url":"https://github.com/MajorHe1"},{"login":"pbting","avatar_url":"https://avatars.githubusercontent.com/u/11469671?v=4","html_url":"https://github.com/pbting"},{"login":"zhaoyuguang","avatar_url":"https://avatars.githubusercontent.com/u/10150229?v=4","html_url":"https://github.com/zhaoyuguang"},{"login":"zongtanghu","avatar_url":"https://avatars.githubusercontent.com/u/5010883?v=4","html_url":"https://github.com/zongtanghu"},{"login":"mercyblitz","avatar_url":"https://avatars.githubusercontent.com/u/533114?v=4","html_url":"https://github.com/mercyblitz"},{"login":"IanCao","avatar_url":"https://avatars.githubusercontent.com/u/32847163?v=4","html_url":"https://github.com/IanCao"},{"login":"ZZQ001010","avatar_url":"https://avatars.githubusercontent.com/u/33930711?v=4","html_url":"https://github.com/ZZQ001010"}]
28 changes: 4 additions & 24 deletions src/components/markdownSet/BlogTop.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Button from "@components/common/Button.astro";
import { useTranslations } from "@i18n/util";
const t = useTranslations(Astro);
const { source, title = "", type = "home", category } = Astro.props;
const { source, title = "", type = "home", category, activeCategory = "" } = Astro.props;
const backIconMap = {
"blog-sub": "/blog",
Expand All @@ -22,19 +22,12 @@ const backIconMap = {
<div class="blog_header_title">{title}</div>
<div class="blog_category_menu">
{
type === "home" &&
category &&
(type === "home" || type == "blog-sub") &&
category &&
category.map((category) => {
return (
// <a
// class="blog_menu_item"
// href={category.href}
// aria-current = {}
// >
// {category.title}
// </a>
<Button
type="primary"
type={category.type == activeCategory? "active": "primary"}
href={category.href}
class="rounded-3xl mr-4 mb-2"
>
Expand All @@ -43,19 +36,6 @@ const backIconMap = {
);
})
}
{
type !== "home" && (
<Button
type="primary"
href={backIconMap[type]}
class="rounded-3xl"
visibility={false}
>
<Icon name="left-arrow" class="text-lg align-middle" />
<span class="ml-1">BACK</span>
</Button>
)
}
</div>
</BaseContainer>
</div>
Expand Down
10 changes: 10 additions & 0 deletions src/components/markdownSet/MarkdownDetail.astro
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ const { title, description, date, updatedDate, heroImage, author } =
padding: 1.5rem;
color: rgb(var(--gray-dark));
}
.nacos-prose a{
display: inline-block;
text-decoration: none;
}
.nacos-prose ul {
padding-left: 40px;
}
.nacos-prose ul li {
list-style-type: disc;
}
.title {
margin-bottom: 1em;
padding: 1em 0;
Expand Down
77 changes: 77 additions & 0 deletions src/components/markdownSet/SimpleCard.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
import Button from '@components/common/Button.astro';
import moment from "moment";
import { useTranslations } from "@i18n/util";
const t = useTranslations(Astro);
export type Props = {
source: string;
post: {
slug: string;
body: string;
collection: string;
excerpt?: string;
data: {
title: string;
description: string;
date: string;
keywords?: any[];
};
};
posterWidth?: string;
type?: string;
index?: number;
useAnchor?: boolean;
};
const { post, source, posterWidth, type = "blog",index = 0, class: className = "", useAnchor=false, } = Astro.props;
---

<div class={"card h-[332px] p-[24px] bg-gray-01 shadow-none w-full flex" + className}>
<!-- 锚点 -->
{useAnchor?<a name={post.slug} class={"absolute z-[-100] top-[-4rem]"}></a>:null}

<p class="text-gray-07 text-xs font-normal">
{moment(post.data.date).format("MMMM D, YYYY")}
</p>
<h2 class="card-title text-gray-14 leading-8 line-clamp-2 mb-3 font-normal text-xl mt-3 truncate">
{post.data.title}
</h2>

<div class="w-full text-lg text-gart-14 leading-8 overflow-hidden">
{post.excerpt || post.data.description}
</div>

<Button
size="large"
type="card"
href={`/blog/${post.slug}/?source=${source}`}
class="rounded-3xl text-xs absolute bottom-3 bg-gray-02"
>
{t('blog.card.read.artile')}
</Button>
</div>

<style>
.card {
transition:
transform 0.2s,
box-shadow 0.2s;
}
.card:hover {
transition:
transform 0.2s,
box-shadow 0.2s;
transform: translateY(-4px);
box-shadow:
4px 4px 8px rgba(0, 0, 0, 0.1),
-4px -4px 8px rgba(0, 0, 0, 0.1);
}
a {
text-decoration: none;
color: inherit;
}
h2 {
min-height: 3rem;
}
</style>
151 changes: 151 additions & 0 deletions src/components/markdownSet/SimpleContainer.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
---
import BaseContainer from '@components/common/BaseContainer.astro';
import Pagination from "@components/common/Pagination.astro";
import SimpleCard from "@components/markdownSet/SimpleCard.astro";
interface Post {
slug: string;
body: string;
collection: string;
data: {
title: string;
description: string;
date: string;
keywords?: any[];
};
};
interface Props {
pageList: Post[];
allPages?: string[];
}
const { pageList, allPages } = Astro.props;
// Get word for mdx
const getExcerpt = (content, length = 200, defaultExcerpt = '') => {
try {
const strippedContent = content.replace(/(<([^>]+)>)/gi, '');
const plainText = strippedContent.replace(/[#>*-]|\[.*?\]\(.*?\)|\!\[.*?\]\(.*?\)/g, '');
let excerpt = plainText.substring(0, length);
if (plainText.length > length) {
excerpt += '...';
};
return excerpt;
} catch(error) {
return defaultExcerpt;
};
};
if(pageList && pageList.length) {
pageList.forEach(item => {
item.excerpt = getExcerpt(item.body, 120, item.data?.description);
});
};
---

<BaseContainer class="flex justify-between">
<div class="max-w-[200px] min-w-[200px] hidden 2xl:block xl:block lg:block">
<div class="text-lg text-gray-08 mb-[32px]">文章</div>
<div class="text-lg text-gray-14">
{
pageList.map(post=>{
return (
<a
class="text-gray-14 no-underline font-normal block mb-[24px]"
href={`#${post.slug}`}
>
{ post.data.title }
</a>
);
})
}
</div>
</div>

<ul class="flex-1 blog-all grid grid-cols-1 gap-6 place-items-stretch 2xl:ml-[100px] xl:ml-[80px] lg:ml-[50px] md:ml-[0px]">
{
pageList.map((post) => (
<SimpleCard
post={post as Post}
source="blog_all"
useAnchor={true}
/>
))
}
</ul>
</BaseContainer>

<style>
main {
width: 960px;
}
ul {
display: flex;
flex-wrap: wrap;
gap: 2rem;
list-style-type: none;
margin: 0;
padding: 0;
}
ul li {
width: calc(50% - 1rem);
}
ul li * {
text-decoration: none;
transition: 0.2s ease;
}
ul li:first-child {
width: 100%;
margin-bottom: 1rem;
text-align: center;
}
ul li:first-child img {
width: 100%;
}
ul li:first-child .title {
font-size: 2.369rem;
}
ul li img {
margin-bottom: 0.5rem;
border-radius: 12px;
}
ul li a {
display: block;
}
.title {
margin: 0;
color: rgb(var(--black));
line-height: 1;
}
.date {
margin: 0;
color: rgb(var(--gray));
}
ul li a:hover h4,
ul li a:hover .date {
color: rgb(var(--accent));
}
ul a:hover img {
box-shadow: var(--box-shadow);
}
@media (max-width: 50rem) {
.blog-all {
padding: 0 1.5rem;
}
ul {
gap: 0.5em;
}
ul li {
width: 100%;
text-align: center;
}
ul li:first-child {
margin-bottom: 0;
}
ul li:first-child .title {
font-size: 1.563em;
}
}
</style>
17 changes: 11 additions & 6 deletions src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export const i18nMap = {
}

export const BLOG_CATEGORY = [
{
type: 'all',
title: '全部文章',
href: '/blog'
},
{
type: 'article',
title: '技术文章',
Expand All @@ -77,12 +82,12 @@ export const BLOG_CATEGORY = [
title: '最佳实践',
href: '/blog/case'
},
{
type: 'all',
title: '全部文章',
href: '/blog/all'
},
]
];

export const BLOG_CATEGORY_EN = BLOG_CATEGORY.map(item => ({
...item,
href: '/en' + item.href
}));

export const NEWS_CATEGORY = [
{
Expand Down
Loading

0 comments on commit 13cc4c5

Please sign in to comment.