feat: bump the astro to v5.
This commit is contained in:
parent
3433ed7155
commit
4532101db1
@ -196,7 +196,7 @@ to get it worked everywhere.
|
||||
This weblog is deployed on the [zeabur](https://zeabur.com) platform.
|
||||
You can check their documents and get your own weblog to be published without any budget at first.
|
||||
|
||||
Or you can host on your own machine. Use [Dockerfile](./docs/Dockerfile) to build an image and run it locally.
|
||||
Or you can host on your own machine. Use [Dockerfile](./Dockerfile) to build an image and run it locally.
|
||||
|
||||
The comment system is leverage the [Artalk](https://artalk.js.org), a self-hosted comment system.
|
||||
You should host it on your own machine.
|
||||
@ -222,8 +222,8 @@ You should host it on your own machine.
|
||||
The source code of this blog is licensed under the [MIT](LICENSE) license,
|
||||
feel to free to use it without any legal risks.
|
||||
|
||||
The [content](src/content) of this blog's posts is licensed under the
|
||||
[CC BY-NC-SA 4.0](src/content/LICENSE) license.
|
||||
The [content](content) of this blog's posts is licensed under the
|
||||
[CC BY-NC-SA 4.0](content/LICENSE) license.
|
||||
|
||||
### Logo Fonts License
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import mdx from '@astrojs/mdx';
|
||||
import zeabur from '@zeabur/astro-adapter/serverless';
|
||||
import node from '@astrojs/node';
|
||||
import { uploader } from 'astro-uploader';
|
||||
import { defineConfig, envField } from 'astro/config';
|
||||
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
|
||||
@ -22,27 +22,26 @@ export default defineConfig({
|
||||
service: !options.isProd() ? { entrypoint: './plugins/resize', config: {} } : undefined,
|
||||
},
|
||||
experimental: {
|
||||
contentLayer: true,
|
||||
contentIntellisense: true,
|
||||
env: {
|
||||
schema: {
|
||||
// Postgres Database
|
||||
POSTGRES_HOST: envField.string({ context: 'server', access: 'secret' }),
|
||||
POSTGRES_PORT: envField.number({ context: 'server', access: 'secret' }),
|
||||
POSTGRES_USERNAME: envField.string({ context: 'server', access: 'secret' }),
|
||||
POSTGRES_PASSWORD: envField.string({ context: 'server', access: 'secret' }),
|
||||
POSTGRES_DATABASE: envField.string({ context: 'server', access: 'secret' }),
|
||||
// Artalk Comment
|
||||
ARTALK_SCHEME: envField.string({ context: 'server', access: 'secret' }),
|
||||
ARTALK_HOST: envField.string({ context: 'server', access: 'secret' }),
|
||||
ARTALK_PORT: envField.number({ context: 'server', access: 'secret' }),
|
||||
// Build the Open Graph
|
||||
BUILD_OPEN_GRAPH: envField.boolean({ context: 'server', access: 'public', default: true }),
|
||||
// Upload the files
|
||||
UPLOAD_STATIC_FILES: envField.boolean({ context: 'server', access: 'public', default: false }),
|
||||
},
|
||||
validateSecrets: true,
|
||||
},
|
||||
env: {
|
||||
schema: {
|
||||
// Postgres Database
|
||||
POSTGRES_HOST: envField.string({ context: 'server', access: 'secret' }),
|
||||
POSTGRES_PORT: envField.number({ context: 'server', access: 'secret' }),
|
||||
POSTGRES_USERNAME: envField.string({ context: 'server', access: 'secret' }),
|
||||
POSTGRES_PASSWORD: envField.string({ context: 'server', access: 'secret' }),
|
||||
POSTGRES_DATABASE: envField.string({ context: 'server', access: 'secret' }),
|
||||
// Artalk Comment
|
||||
ARTALK_SCHEME: envField.string({ context: 'server', access: 'secret' }),
|
||||
ARTALK_HOST: envField.string({ context: 'server', access: 'secret' }),
|
||||
ARTALK_PORT: envField.number({ context: 'server', access: 'secret' }),
|
||||
// Build the Open Graph
|
||||
BUILD_OPEN_GRAPH: envField.boolean({ context: 'server', access: 'public', default: true }),
|
||||
// Upload the files
|
||||
UPLOAD_STATIC_FILES: envField.boolean({ context: 'server', access: 'public', default: false }),
|
||||
},
|
||||
validateSecrets: true,
|
||||
},
|
||||
integrations: [
|
||||
mdx({
|
||||
@ -68,7 +67,9 @@ export default defineConfig({
|
||||
}),
|
||||
openGraph(),
|
||||
],
|
||||
adapter: zeabur(),
|
||||
adapter: node({
|
||||
mode: 'standalone',
|
||||
}),
|
||||
markdown: {
|
||||
gfm: true,
|
||||
shikiConfig: {
|
||||
|
2447
package-lock.json
generated
2447
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -42,10 +42,10 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/mdx": "^3.1.9",
|
||||
"@astrojs/mdx": "^4.0.1",
|
||||
"@astrojs/node": "^9.0.0",
|
||||
"@astrojs/rss": "^4.0.9",
|
||||
"@zeabur/astro-adapter": "^1.0.6",
|
||||
"astro": "^4.16.16",
|
||||
"astro": "^5.0.1",
|
||||
"drizzle-orm": "^0.36.4",
|
||||
"fuse.js": "^7.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { imageMetadata } from '@/helpers/images';
|
||||
import { urlJoin } from '@/helpers/tools';
|
||||
import options from '@/options';
|
||||
import { glob } from 'astro/loaders';
|
||||
import { defineCollection, z } from 'astro:content';
|
||||
|
||||
export const defaultCover = '/images/default-cover.jpg';
|
||||
@ -48,7 +49,7 @@ const toc = () =>
|
||||
|
||||
// Categories Collection
|
||||
const categoriesCollection = defineCollection({
|
||||
type: 'data',
|
||||
loader: glob({ pattern: '**\/[^_]*.yml', base: './src/content/categories' }),
|
||||
schema: z.object({
|
||||
name: z.string().max(20),
|
||||
slug: slug(),
|
||||
@ -59,7 +60,7 @@ const categoriesCollection = defineCollection({
|
||||
|
||||
// Friends Collection
|
||||
const friendsCollection = defineCollection({
|
||||
type: 'data',
|
||||
loader: glob({ pattern: '**\/[^_]*.yml', base: './src/content/friends' }),
|
||||
schema: z.array(
|
||||
z
|
||||
.object({
|
||||
@ -82,7 +83,7 @@ const friendsCollection = defineCollection({
|
||||
|
||||
// Posts Collection
|
||||
const postsCollection = defineCollection({
|
||||
type: 'content',
|
||||
loader: glob({ pattern: '**\/[^_]*.mdx', base: './src/content/posts' }),
|
||||
schema: z.object({
|
||||
title: z.string().max(99),
|
||||
date: z.date(),
|
||||
@ -100,7 +101,7 @@ const postsCollection = defineCollection({
|
||||
|
||||
// Pages Collection
|
||||
const pagesCollection = defineCollection({
|
||||
type: 'content',
|
||||
loader: glob({ pattern: '**\/[^_]*.mdx', base: './src/content/pages' }),
|
||||
schema: z.object({
|
||||
title: z.string().max(99),
|
||||
date: z.date(),
|
||||
@ -116,7 +117,7 @@ const pagesCollection = defineCollection({
|
||||
|
||||
// Tags Collection
|
||||
const tagsCollection = defineCollection({
|
||||
type: 'data',
|
||||
loader: glob({ pattern: '**\/[^_]*.yml', base: './src/content/tags' }),
|
||||
schema: z.array(
|
||||
z.object({
|
||||
name: z.string().max(20),
|
@ -1,5 +1,5 @@
|
||||
import serverRenderer from '@astrojs/mdx/server.js';
|
||||
import { experimental_AstroContainer as AstroContainer, type ContainerRenderOptions } from 'astro/container';
|
||||
import serverRenderer from 'astro/jsx/server.js';
|
||||
import type { AstroComponentFactory } from 'astro/runtime/server/index.js';
|
||||
|
||||
const container = await AstroContainer.create();
|
||||
|
@ -1,5 +1,6 @@
|
||||
import fs from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import sharp from 'sharp';
|
||||
import options from '../../options';
|
||||
import { urlJoin } from './tools';
|
||||
|
||||
@ -54,8 +55,6 @@ export const blurStyle = (image: Image) => ({
|
||||
|
||||
// Copied and modified https://github.com/zce/velite/blob/main/src/assets.ts
|
||||
export const imageMetadata = async (publicPath: string): Promise<Image> => {
|
||||
const { default: sharp } = await import('sharp');
|
||||
|
||||
if (!publicPath.startsWith('/')) {
|
||||
throw new Error('We only support image path in "public/images" directory. The path should start with "/images/".');
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { defaultCover } from '@/content/config.ts';
|
||||
import { defaultCover } from '@/content.config';
|
||||
import options from '@/options';
|
||||
import { getCollection, getEntry, type Render } from 'astro:content';
|
||||
import { getCollection, getEntry, render, type RenderResult } from 'astro:content';
|
||||
import { pinyin } from 'pinyin-pro';
|
||||
|
||||
// Import the collections from the astro content.
|
||||
@ -19,35 +19,36 @@ export type Friend = (typeof friendsCollection)[number]['data'][number];
|
||||
export type Page = (typeof pagesCollection)[number]['data'] & {
|
||||
slug: string;
|
||||
permalink: string;
|
||||
render: () => Render['.mdx'];
|
||||
render: () => Promise<RenderResult>;
|
||||
};
|
||||
export type Post = (typeof postsCollection)[number]['data'] & {
|
||||
slug: string;
|
||||
permalink: string;
|
||||
render: () => Render['.mdx'];
|
||||
raw: () => Promise<string>;
|
||||
render: () => Promise<RenderResult>;
|
||||
raw: () => Promise<string | undefined>;
|
||||
};
|
||||
export type Tag = (typeof tagsCollection)[number]['data'][number] & { counts: number; permalink: string };
|
||||
|
||||
// Translate the Astro content into the original content for dealing with different configuration types.
|
||||
export const friends: Friend[] = friendsCollection[0].data;
|
||||
export const friends: Friend[] = friendsCollection.flatMap((friends) => friends.data);
|
||||
|
||||
// Override the website for local debugging
|
||||
export const pages: Page[] = pagesCollection
|
||||
.filter((page) => page.data.published || !options.isProd())
|
||||
.map((page) => ({
|
||||
slug: page.slug,
|
||||
permalink: `/${page.slug}`,
|
||||
render: page.render,
|
||||
slug: page.id,
|
||||
permalink: `/${page.id}`,
|
||||
render: async () => await render(await getEntry('pages', page.id)),
|
||||
...page.data,
|
||||
}));
|
||||
export const posts: Post[] = postsCollection
|
||||
.filter((post) => post.data.published || !options.isProd())
|
||||
.map((post) => ({
|
||||
slug: post.slug,
|
||||
permalink: `/posts/${post.slug}`,
|
||||
render: post.render,
|
||||
slug: post.id,
|
||||
permalink: `/posts/${post.id}`,
|
||||
render: async () => await render(await getEntry('posts', post.id)),
|
||||
raw: async () => {
|
||||
const entry = await getEntry('posts', post.slug);
|
||||
const entry = await getEntry('posts', post.id);
|
||||
return entry.body;
|
||||
},
|
||||
...post.data,
|
||||
|
@ -4,7 +4,7 @@ import Fuse from 'fuse.js';
|
||||
interface PostItem {
|
||||
title: string;
|
||||
slug: string;
|
||||
raw: string;
|
||||
raw: string | undefined;
|
||||
tags: string[];
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig.json",
|
||||
"extends": "astro/tsconfigs/strict",
|
||||
"include": [".astro/types.d.ts", "**/*"],
|
||||
"exclude": ["dist"],
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"strict": true,
|
||||
|
Loading…
Reference in New Issue
Block a user