Skip to content

Commit

Permalink
feat: upgrade astrojs@v4
Browse files Browse the repository at this point in the history
  • Loading branch information
cirry committed Jan 24, 2024
1 parent 5652408 commit f1a3748
Show file tree
Hide file tree
Showing 88 changed files with 5,036 additions and 3,534 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ trim_trailing_whitespace = true

[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
trim_trailing_whitespace = false
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# build output
dist/
.output/
# generated types
.astro/
.vscode
.idea

# dependencies
node_modules/
Expand All @@ -18,7 +21,3 @@ pnpm-debug.log*

# macOS-specific files
.DS_Store
.astro
.idea
.vscode
*.swp
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

207 changes: 194 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
## Astro Theme YI

[Demo](https://astro-yi.cirry.cn/)

**注意:此项目使用Astro V2版本开发功能足够完善和代码精简。Astro版本更新太快,作者决定用V4版本重构此项目,尽请期待**
Demo地址:[Astro-Theme-Yi](https://astro-yi.cn)

一个以内容展示为主的Astro博客主题,YI也就是易,简简单单的意思。

![](http://qn.cirry.cn/home.png)
![](https://pic-19d9.obs.cn-east-3.myhuaweicloud.com/astroyi/home.png)

![](http://qn.cirry.cn/post-white.png)
![](https://pic-19d9.obs.cn-east-3.myhuaweicloud.com/astroyi/post-white.png)

🔥 Features
### 🔥 Features

- [x] 支持多端显示
- [x] 支持暗黑模式
Expand All @@ -20,25 +18,208 @@
- [x] 支持文章草稿和分页
- [x] 支持Waline评论系统
- [x] 添加动态页面
- [x] 博客图片懒加载和缩放
- [x] 图片懒加载和缩放
- [x] 支持文章固定链接
- [x] 支持自定义

......

👨🏻‍💻 Running Locally
### 👨🏻‍💻 Running Locally

推荐使用`nodejs >= 16``pnpm >= 7`
推荐使用`nodejs >= 18``pnpm >= 8`

如何使用:

```bash
git clone https://github.com/cirry/astro-yi.git
cd astro-yi
pnpm i
npm run dev
npm run dev # 预览
```

将您喜欢的文章写入`src/content/blog`文件夹下,将想要发的动态写入`src/content/feed`文件夹下。

更多写作技巧内容请查看文章: [Astro-YI Write Skill](https://cirry.cn/blog/frontend/astro/config-and-write-skill)

```bash
npm run build # 打包
```

将您喜欢的文章写入`src/content/blog`文件夹下,将想要发的动态写入`src/content/activity`文件夹下。
打包完成后,将在根目录下生成dist文件夹,将dist文件夹上传到网页服务器目录下即可。

## Configuration

`src/const.ts`文件中,可以根据您的需要进行一些修改。

```ts
// Place any global data in this file.
// You can import this data from anywhere in your site by using the `import` keyword.

/**
* 站点信息
* title:网站标题
* description:网站描述
* author:作者
* motto:格言
* url:网站地址
* recentBlogSize:最近文章数量
* archivePageSize:归档页面每页显示的数量
* postPageSize:文章页面每页显示的数量
* indexPageSize:首页每页显示的数量
* beian:备案号
*/
export const site = {
title: 'Astro Theme Yi',
description: 'You only live once,so what are you waiting for?',
author: "Cirry",
motto: '最重要的事情只有一件',
url: 'https://astro-yi.cn',
recentBlogSize: 5,
archivePageSize: 25,
postPageSize: 10,
indexPageSize: 10,
beian: ''
}

更多写作技巧内容请查看文章: [Astro-Yi主题配置和写作技巧](https://cirry.cn/blog/frontend/astro/config-and-write-skill)
/**
* busuanzi:是否开启不蒜子统计功能
*/
export const config = {
busuanzi: false,
}

/**
* 导航栏
*/
export const categories = [
{
name: "首页",
iconClass: "ri-home-4-line",
href: "/",
},
{
name: "博客",
iconClass: "ri-draft-line",
href: "/blog/1",
},
{
name: "动态",
iconClass: "ri-lightbulb-flash-line",
href: "/feed/1",
},
{
name: "归档",
iconClass: "ri-archive-line",
href: "/archive/1",
},
{
name: "留言",
iconClass: "ri-chat-1-line",
href: "/message",
},
{
name: "搜索",
iconClass: "ri-search-line",
href: "/search",
},
{
name: "更多",
iconClass: "ri-more-fill",
href: "javascript:void(0);",
children: [
{
name: '关于本站',
iconClass: 'ri-information-line',
href: '/about',
},
{
name: '友情链接',
iconClass: 'ri-user-5-line',
href: '/friends',
},
]
}
]

/**
* 个人链接地址
*/
export const infoLinks = [
{
icon: "ri-bilibili-fill",
name: "bilibili",
outlink: "https://space.bilibili.com/89561082",
},
{
icon: 'ri-mail-fill',
name: 'cdxtrv@qq.com',
outlink: 'mailto:cdxtrv@qq.com',
},
{
icon: 'ri-github-fill',
name: 'github',
outlink: 'https://github.com/cirry',
},
{
icon: 'ri-rss-fill',
name: 'rss',
outlink: 'https://astro-yi.cn/rss.xml',
}
]

/**
* 赞赏功能
* enable 是否开启功能
*/
export const donate = {
enable: false,
tip: "感谢大佬送来的咖啡☕",
wechatQRCode: "/WeChatQR.png",
alipayQRCode: "/AliPayQR.png",
paypalUrl: "https://paypal.me/cirry0?country.x=C2&locale.x=zh_XC",
}

/**
* 友情链接配置
*/
export const friendlyLinks =
[
{
name: '菜小牛的博客',
url: 'https://cirry.cn',
avatar: "https://cirry.cn/avatar.png",
description: '前端开发的日常'
},
]

/**
* 评论功能
* enable 是否开启评论功能
* serverUrl 评论服务器地址
* pageSize 每页评论数量
* wordLimit 评论内容字数限制,默认为空不限制
* count 最近评论侧边栏评论数量
* pageview 是否开启阅读数统计
* reaction 是否开启表情
* requiredMeta 必填字段
*/
export const comment = {
enable: false,
serverUrl: "https://xxxxxxx.com",
pageSize: 20,
wordLimit: '',
count: 5,
pageview: true,
reaction: false,
requiredMeta: ["nick", "mail"],
}
```

### 额外注意:

在根目录下的`astro.config.mjs`中,建议修改`site`属性用来正确生成站点地图。
```js
export default defineConfig({
site: 'https://astro-yi.cn',// 修改为您自己的网站地址
// ...
})
```
65 changes: 13 additions & 52 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,59 +1,20 @@
import { defineConfig } from 'astro/config';
// 添加yml支持
import yaml from '@rollup/plugin-yaml';
// 新版node需要改写path和dirname
import path from 'path';
// 最新 node 核心包的导入写法
import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
// 获取 __filename 的 ESM 写法
const __filename = fileURLToPath(import.meta.url);
// 获取 __dirname 的 ESM 写法
const __dirname = dirname(fileURLToPath(import.meta.url));
import {defineConfig} from 'astro/config';
import mdx from '@astrojs/mdx';

// https://astro.build/config
import tailwind from "@astrojs/tailwind";

// https://astro.build/config
import sitemap from "@astrojs/sitemap";

// https://astro.build/config
import solidJs from "@astrojs/solid-js";

import { visit } from 'unist-util-visit'

function myRemarkPluginToLazyLoadImage() {
return (tree) => {
visit(tree, (node, index) => {
if (node.type === 'image') {
node.alt = node.url
node.url = ''
}
})
}
}
import sitemap from '@astrojs/sitemap';
import tailwind from '@astrojs/tailwind';
import solid from '@astrojs/solid-js';
import {remarkModifiedTime} from "./src/remarkPlugin/remark-modified-time.mjs";

// https://astro.build/config
export default defineConfig({
site: "https://demo.demo/",
integrations: [tailwind({
config: {
applyBaseStyles: false,
},
}), sitemap(), solidJs()],
vite: {
plugins: [yaml()],
resolve: {
alias: {
'$': path.resolve(__dirname, './src')
}
}
},
site: 'https://astro-yi.cn',
integrations: [mdx(), sitemap(), tailwind(), solid()],

markdown: {
remarkPlugins: [myRemarkPluginToLazyLoadImage],
// remarkPlugins: [remarkReadingTime],
remarkPlugins: [remarkModifiedTime],
shikiConfig: {
// Choose from Shiki's built-in themes (or add your own)
// https://github.com/shikijs/shiki/blob/main/docs/themes.md
theme: 'dracula-soft',
// Add custom languages
// Note: Shiki has countless langs built-in, including .astro!
Expand All @@ -62,5 +23,5 @@ export default defineConfig({
// Enable word wrap to prevent horizontal scrolling
wrap: false
}
}
});
},
});
Loading

0 comments on commit f1a3748

Please sign in to comment.