Skip to content

Commit

Permalink
学习 Astro
Browse files Browse the repository at this point in the history
  • Loading branch information
丫丫的刀了 committed Oct 27, 2024
1 parent da10892 commit 5f3444e
Show file tree
Hide file tree
Showing 27 changed files with 5,971 additions and 26,467 deletions.
3 changes: 2 additions & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export default defineConfig({
site: 'https://overlookart.github.io',
base: '/ArtWebsite',
// 集成
integrations: [vue(), tailwind(), db()]
integrations: [vue({devtools: true}), tailwind(), db()],
renderers: ['@astrojs/renderer-vue'],
});
32,129 changes: 5,867 additions & 26,262 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/components/Astro/Background.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

<div class=" bg-center bg-no-repeat bg-cover fixed top-0 -z-10 w-full h-full bg-sitebg"></div>
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions src/components/Astro/Head.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
import { ViewTransitions } from 'astro:transitions';
const { title } = Astro.props;
---

<head>
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<title>{title}</title>
<ViewTransitions />
</head>
9 changes: 9 additions & 0 deletions src/components/Astro/Header.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
import Navigation from '../Astro/Navigation.astro'
---

<header>
<nav>
<Navigation/>
</nav>
</header>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import '../styles/global.css'
import '../../styles/global.css'
---
<div class="nav-links">
<a href="/ArtWebsite/">首页</a>
Expand Down
File renamed without changes.
8 changes: 0 additions & 8 deletions src/components/Hamburger.astro

This file was deleted.

11 changes: 0 additions & 11 deletions src/components/Header.astro

This file was deleted.

2 changes: 2 additions & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/// <reference path="../.astro/db-types.d.ts" />
/// <reference path="../.astro/types.d.ts" />
/// <reference types="astro/client" />
56 changes: 26 additions & 30 deletions src/layouts/BaseLayout.astro
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
---
import Header from "../components/Header.astro";
import Footer from "../components/Footer.astro";
import Head from "../components/Astro/Head.astro";
import Background from "../components/Astro/Background.astro";
import Header from "../components/Astro/Header.astro";
import Footer from "../components/Astro/Footer.astro";
import { ViewTransitions } from 'astro:transitions';
import '../styles/global.css'
const { pageTitle } = Astro.props
---

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<title>{pageTitle}</title>
</head>
<Head />
<body>
<Background />
<script type="module" src="/src/scripts/main.js"></script>
<Header />
<h1>{pageTitle}</h1>
<slot />
<Footer />
<script>
import "../scripts/menu.js";
</script>
<div class="container mx-auto">
<div class="flex h-screen shadow-gray-600 py-4">
<div class="flex-none py-2 backdrop-blur-md bg-white/5 rounded-l-lg w-[215px]" style="box-shadow: 20px 20px 20px 20px rgba(0, 0, 0, 0.1);">
<p>可被其他模版覆盖的左侧内容</p>
</div>
<div id="content" class="flex flex-col grow backdrop-blur-md bg-white/0 rounded-r-lg" style="box-shadow: 20px 20px 20px 20px rgba(0, 0, 0, 0.1);">
<div class="overflow-scroll flex">
<div class="grow">
<slot></slot>
</div>
<div class="w-[215px] h-full mx-auto overflow-scroll">
<p>请使用 block "rightSideBar" 定义右侧内容</p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

<style is:global>
:root {
--accent: 136, 58, 234;
--accent-light: 224, 204, 250;
--accent-dark: 49, 10, 101;
--accent-gradient: linear-gradient(
45deg,
rgb(var(--accent)),
rgb(var(--accent-light)) 30%,
white 60%
);
}
</style>
19 changes: 19 additions & 0 deletions src/layouts/MarkdownLayout.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
import BaseLayout from './BaseLayout.astro';
const { frontmatter } = Astro.props;
---
<BaseLayout pageTitle={frontmatter.title}>
<p><em>{frontmatter.description}</em></p>
<p>{frontmatter.pubDate.toString().slice(0,10)}</p>

<p>Written by: {frontmatter.author}</p>


<div class="flex">
{frontmatter.tags.map((tag) => (
<p class="m-1 border-[1px] border-x-cyan-100 rounded-md px-2"><a href={`/tags/${tag}`}>{tag}</a></p>
))}
</div>

<slot />
</BaseLayout>
39 changes: 0 additions & 39 deletions src/layouts/MarkdownPostLayout.astro

This file was deleted.

4 changes: 2 additions & 2 deletions src/pages/blog.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import BaseLayout from '../layouts/BaseLayout.astro'
import BlogPost from '../components/BlogPost.astro';
const allPosts = await Astro.glob('../pages/posts/*.md');
import BlogPost from '../components/Astro/BlogPost.astro';
const allPosts = await Astro.glob('../pages/posts/**/*.md');
const pageTitle = '我的 Astro 学习博客'
---
<BaseLayout pageTitle={pageTitle}>
Expand Down
74 changes: 0 additions & 74 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
import Card from '../components/Card.astro';
import BaseLayout from '../layouts/BaseLayout.astro';
const pageTitle = "首页"
---
Expand All @@ -10,77 +9,4 @@ const pageTitle = "首页"
To get started, open the directory <code>src/pages</code> in your project.<br />
<strong>Code Challenge:</strong> Tweak the "Welcome to Astro" message above.
</p>
<ul role="list" class="link-card-grid">
<Card
href="https://docs.astro.build/"
title="Documentation"
body="Learn how Astro works and explore the official API docs."
/>
<Card
href="https://astro.build/integrations/"
title="Integrations"
body="Supercharge your project with new frameworks and libraries."
/>
<Card
href="https://astro.build/themes/"
title="Themes"
body="Explore a galaxy of community-built starter themes."
/>
<Card
href="https://astro.build/chat/"
title="Community"
body="Come say hi to our amazing Discord community. ❤️"
/>
</ul>
</BaseLayout>


<style>
.astro-a {
position: absolute;
top: -32px;
left: 50%;
transform: translatex(-50%);
width: 220px;
height: auto;
z-index: -1;
}
h1 {
font-size: 4rem;
font-weight: 700;
line-height: 1;
text-align: center;
margin-bottom: 1em;
}
.text-gradient {
background-image: var(--accent-gradient);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-size: 400%;
background-position: 0%;
}
.instructions {
margin-bottom: 2rem;
border: 1px solid rgba(var(--accent-light), 25%);
background: linear-gradient(rgba(var(--accent-dark), 66%), rgba(var(--accent-dark), 33%));
padding: 1.5rem;
border-radius: 8px;
}
.instructions code {
font-size: 0.8em;
font-weight: bold;
background: rgba(var(--accent-light), 12%);
color: rgb(var(--accent-light));
border-radius: 4px;
padding: 0.3em 0.4em;
}
.instructions strong {
color: rgb(var(--accent-light));
}
.link-card-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(24ch, 1fr));
gap: 2rem;
padding: 0;
}
</style>
18 changes: 18 additions & 0 deletions src/pages/posts/Astro/Start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
layout: '../../../layouts/MarkdownLayout.astro'
title: 'Astro 的开始之旅'
pubDate: 2024-10-27
description: '这是将记录 Astro 环境搭建、使用、以及遇到的问题的学习笔记。'
author: 'Astro 学习者'
tags: ["astro", "blogging", "learning in public"]
---

# Hello, Astro!

这是我的第一篇文章,欢迎来到 Astro 的世界!

## 搭建 Astro 环境

> 1. 安装 Node.js `v18.17.1``20.3.0` 或更高版本。不支持 ~~v19~~
> 2. 编辑器:推荐使用 VS Code 并安装 Astro 的官方扩展
> 3. 安装 Astro CLI `npm install -g astro`
2 changes: 1 addition & 1 deletion src/pages/posts/post-1.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: '../../layouts/MarkdownPostLayout.astro'
layout: '../../layouts/MarkdownLayout.astro'
title: '我的第一篇博客文章'
pubDate: 2022-07-01
description: '这是我 Astro 博客的第一篇文章。'
Expand Down
2 changes: 1 addition & 1 deletion src/pages/posts/post-2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: '../../layouts/MarkdownPostLayout.astro'
layout: '../../layouts/MarkdownLayout.astro'
title: 我的第二篇博客文章
author: Astro 学习者
description: "学习了一些 Astro 后,我根本停不下来!"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/posts/post-3.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: '../../layouts/MarkdownPostLayout.astro'
layout: '../../layouts/MarkdownLayout.astro'
title: 我的第三篇博客文章
author: Astro 学习者
description: "我遇到了一些问题,但是在社区里面提问真的很有帮助!"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/posts/post-4.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: '../../layouts/MarkdownPostLayout.astro'
layout: '../../layouts/MarkdownLayout.astro'
title: '我的第四篇博客文章'
author: 'Astro 学习者'
description: "这篇文章会自己出现在列表中!"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/tags/[tag].astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import BaseLayout from '../../layouts/BaseLayout.astro';
import BlogPost from '../../components/BlogPost.astro';
import BlogPost from '../../components/Astro/BlogPost.astro';
export async function getStaticPaths() {
const allPosts = await Astro.glob('../posts/*.md');
Expand Down
1 change: 1 addition & 0 deletions src/scripts/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.debug('加载主脚本')
3 changes: 0 additions & 3 deletions src/scripts/menu.js

This file was deleted.

Loading

0 comments on commit 5f3444e

Please sign in to comment.