Новые изменения в компоненты
This commit is contained in:
parent
faf02848ed
commit
735289481c
7 changed files with 151 additions and 3 deletions
42
frontend/src/components/blog/PostViewCounter.astro
Normal file
42
frontend/src/components/blog/PostViewCounter.astro
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
---
|
||||
import { Icon } from 'astro-icon/components';
|
||||
|
||||
interface Props {
|
||||
views: number;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const { views, className = '' } = Astro.props;
|
||||
|
||||
const formatViews = (n: number) => {
|
||||
if (n >= 1000) {
|
||||
return (n / 1000).toFixed(1).replace(/\.0$/, '') + 'k';
|
||||
}
|
||||
return n.toString();
|
||||
};
|
||||
---
|
||||
|
||||
<div class={`post-view-counter ${className}`}>
|
||||
<Icon name="eye" class="view-icon" />
|
||||
<span class="view-count">{formatViews(views)}</span>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.post-view-counter {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.view-icon {
|
||||
width: 1.1rem;
|
||||
height: 1.1rem;
|
||||
color: #eac26e;
|
||||
}
|
||||
|
||||
.view-count {
|
||||
color: #ffffff;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
Loading…
Add table
Add a link
Reference in a new issue