Skip to content

Commit

Permalink
✨ 优化 Menu 结构
Browse files Browse the repository at this point in the history
  • Loading branch information
Skywt2003 committed Feb 6, 2024
1 parent 78c6f5c commit 0c24715
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 72 deletions.
2 changes: 1 addition & 1 deletion src/components/Header.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import Menu from "./Menu.astro";
import Menu from "./menu/Menu.astro";
---

<header class="container mt-12">
Expand Down
58 changes: 0 additions & 58 deletions src/components/Menu.astro

This file was deleted.

4 changes: 0 additions & 4 deletions src/components/friends/yaml.d.ts

This file was deleted.

51 changes: 51 additions & 0 deletions src/components/menu/Menu.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
interface Props {
includeHome?: boolean;
}
const { includeHome = true } = Astro.props;
interface MenuItem {
name: string;
icon: string;
url: string;
}
import yml from "./config.yml";
---

<ul>
{
includeHome && (
<li>
<a class="link" href="/">
<i class="ri-newspaper-line" />
主页
</a>
</li>
)
}
{
yml.menu.map((item: MenuItem) => (
<li>
<a class="link" href={item.url}>
<i class={item.icon} />
{item.name}
</a>
</li>
))
}
</ul>

<style lang="scss">
ul {
@apply inline-block;

li {
@apply inline-block ml-2;
&:first-child {
@apply ml-0;
}
}
}
</style>
13 changes: 13 additions & 0 deletions src/components/menu/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
menu:
- name: 博客
icon: ri-newspaper-line
url: https://blog.skywt.cn/
- name: 实验室
icon: ri-server-line
url: https://lab.skywt.cn/
- name: 友人
icon: ri-contacts-line
url: https://blog.skywt.cn/friends
- name: 关于
icon: ri-cup-line
url: https://blog.skywt.cn/about
4 changes: 0 additions & 4 deletions src/components/projects/yaml.d.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/components/socials/yaml.d.ts

This file was deleted.

5 changes: 5 additions & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
/// <reference types="astro/client" />

declare module "*.yml" {
const value: any;
export default value;
}
2 changes: 1 addition & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import Layout from "../layouts/Layout.astro";
import Menu from "../components/Menu.astro";
import Menu from "../components/menu/Menu.astro";
import Bento from "../components/bento/Bento.astro";
import ProjectsCards from "../components/projects/ProjectsCards.astro";
import SocialLinks from "../components/socials/SocialLinks.astro";
Expand Down

0 comments on commit 0c24715

Please sign in to comment.