Skip to content

Commit

Permalink
添加 web 后台
Browse files Browse the repository at this point in the history
  • Loading branch information
zouzonghao committed Dec 27, 2024
1 parent c1cf030 commit 089ca68
Show file tree
Hide file tree
Showing 16 changed files with 535 additions and 123 deletions.
209 changes: 103 additions & 106 deletions astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,127 +9,124 @@ import webmanifest from "astro-webmanifest";
import { defineConfig, envField } from "astro/config";
import { expressiveCodeOptions } from "./src/site.config";
import { siteConfig } from "./src/site.config";
import vercel from "@astrojs/vercel";

// Remark plugins
import remarkDirective from "remark-directive"; /* Handle ::: directives as nodes */
import { remarkAdmonitions } from "./src/plugins/remark-admonitions"; /* Add admonitions */
import remarkDirective from "remark-directive";/* Handle ::: directives as nodes */
import { remarkAdmonitions } from "./src/plugins/remark-admonitions";/* Add admonitions */
import { remarkReadingTime } from "./src/plugins/remark-reading-time";

// Rehype plugins
import rehypeExternalLinks from "rehype-external-links";
import rehypeUnwrapImages from "rehype-unwrap-images";

import decapCmsOauth from "astro-decap-cms-oauth";

// https://astro.build/config
export default defineConfig({
image: {
domains: ["webmention.io"],
},
integrations: [
expressiveCode(expressiveCodeOptions),
icon({
iconDir: "public/icons", // 修改:指定自定义图标目录 name = svg文件名
}),
tailwind({
applyBaseStyles: false,
nesting: true,
}),
sitemap(),
mdx(),
robotsTxt(),
webmanifest({
// See: https://github.com/alextim/astro-lib/blob/main/packages/astro-webmanifest/README.md
/**
* required
**/
name: siteConfig.title,
/**
* optional
**/
short_name: "仙人掌主题",
description: siteConfig.description,
lang: siteConfig.lang,
icon: "public/icon.svg", // the source for generating favicon & icons
icons: [
{
src: "icons/apple-touch-icon.png", // used in src/components/BaseHead.astro L:26
sizes: "180x180",
type: "image/png",
},
{
src: "icons/icon-192.png",
sizes: "192x192",
type: "image/png",
},
{
src: "icons/icon-512.png",
sizes: "512x512",
type: "image/png",
},
],
start_url: "/",
background_color: "#1d1f21",
theme_color: "#2bbc8a",
display: "standalone",
config: {
insertFaviconLinks: false,
insertThemeColorMeta: false,
insertManifestLink: false,
},
}),
],
markdown: {
rehypePlugins: [
[
rehypeExternalLinks,
{
rel: ["nofollow, noreferrer"],
target: "_blank",
},
],
rehypeUnwrapImages,
],
remarkPlugins: [remarkReadingTime, remarkDirective, remarkAdmonitions],
remarkRehype: {
footnoteLabelProperties: {
className: [""],
},
output: 'server',
adapter: vercel(),
image: {
domains: ["webmention.io"],
},
integrations: [expressiveCode(expressiveCodeOptions), icon({
iconDir: "public/icons", // 修改:指定自定义图标目录 name = svg文件名
}), tailwind({
applyBaseStyles: false,
nesting: true,
}), sitemap(), mdx(), robotsTxt(), webmanifest({
// See: https://github.com/alextim/astro-lib/blob/main/packages/astro-webmanifest/README.md
/**
* required
**/
name: siteConfig.title,
/**
* optional
**/
short_name: "仙人掌主题",
description: siteConfig.description,
lang: siteConfig.lang,
icon: "public/icon.svg", // the source for generating favicon & icons
icons: [
{
src: "icons/apple-touch-icon.png", // used in src/components/BaseHead.astro L:26
sizes: "180x180",
type: "image/png",
},
{
src: "icons/icon-192.png",
sizes: "192x192",
type: "image/png",
},
{
src: "icons/icon-512.png",
sizes: "512x512",
type: "image/png",
},
],
start_url: "/",
background_color: "#1d1f21",
theme_color: "#2bbc8a",
display: "standalone",
config: {
insertFaviconLinks: false,
insertThemeColorMeta: false,
insertManifestLink: false,
},
}), decapCmsOauth()],
markdown: {
rehypePlugins: [
[
rehypeExternalLinks,
{
rel: ["nofollow, noreferrer"],
target: "_blank",
},
],
rehypeUnwrapImages,
],
remarkPlugins: [remarkReadingTime, remarkDirective, remarkAdmonitions],
remarkRehype: {
footnoteLabelProperties: {
className: [""],
},
footnoteLabel: '脚注:',
},
},
// https://docs.astro.build/en/guides/prefetch/
prefetch: {
},
},
// https://docs.astro.build/en/guides/prefetch/
prefetch: {
defaultStrategy: 'viewport',
prefetchAll: true
},
// ! 改为你的网站地址,不然社交图片无法加载
site: "https://demo.343700.xyz/",
vite: {
optimizeDeps: {
exclude: ["@resvg/resvg-js"],
},
plugins: [rawFonts([".ttf", ".woff"])],
},
env: {
schema: {
WEBMENTION_API_KEY: envField.string({ context: "server", access: "secret", optional: true }),
WEBMENTION_URL: envField.string({ context: "client", access: "public", optional: true }),
WEBMENTION_PINGBACK: envField.string({ context: "client", access: "public", optional: true }),
},
},
// ! 改为你的网站地址,不然社交图片无法加载
site: "https://demo.343700.xyz/",
vite: {
optimizeDeps: {
exclude: ["@resvg/resvg-js"],
},
plugins: [rawFonts([".ttf", ".woff"])],
},
env: {
schema: {
WEBMENTION_API_KEY: envField.string({ context: "server", access: "secret", optional: true }),
WEBMENTION_URL: envField.string({ context: "client", access: "public", optional: true }),
WEBMENTION_PINGBACK: envField.string({ context: "client", access: "public", optional: true }),
},
},
});

function rawFonts(ext: string[]) {
return {
name: "vite-plugin-raw-fonts",
// @ts-expect-error:next-line
transform(_, id) {
if (ext.some((e) => id.endsWith(e))) {
const buffer = fs.readFileSync(id);
return {
code: `export default ${JSON.stringify(buffer)}`,
map: null,
};
}
},
};
return {
name: "vite-plugin-raw-fonts",
// @ts-expect-error:next-line
transform(_, id) {
if (ext.some((e) => id.endsWith(e))) {
const buffer = fs.readFileSync(id);
return {
code: `export default ${JSON.stringify(buffer)}`,
map: null,
};
}
},
};
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dev": "astro dev",
"start": "astro dev",
"build": "astro build",
"postbuild": "pagefind --site dist",
"postbuild": "pagefind --site dist/client --output-path .vercel/output/static/pagefind",
"preview": "astro preview",
"lint": "biome lint .",
"format": "pnpm run format:code && pnpm run format:imports",
Expand All @@ -18,7 +18,9 @@
"@astrojs/rss": "4.0.10",
"@astrojs/sitemap": "3.2.1",
"@astrojs/tailwind": "5.1.3",
"@astrojs/vercel": "^8.0.1",
"astro": "5.0.3",
"astro-decap-cms-oauth": "^0.5.1",
"astro-expressive-code": "^0.38.3",
"astro-icon": "^1.1.4",
"astro-robots-txt": "^1.0.0",
Expand Down
Loading

0 comments on commit 089ca68

Please sign in to comment.