From 0730a865b9856ccbadc4a5e6232bb9f3f3365975 Mon Sep 17 00:00:00 2001 From: Yufan Sheng Date: Wed, 27 Nov 2024 17:25:51 +0800 Subject: [PATCH] chore: change the style of the calendar. --- astro.config.ts | 2 +- options.ts | 2 +- package-lock.json | 66 ++++++-------------- package.json | 6 +- src/components/sidebar/OwspaceCalendar.astro | 8 ++- src/components/sidebar/RandomPosts.astro | 2 +- src/components/sidebar/RandomTags.astro | 2 +- 7 files changed, 33 insertions(+), 55 deletions(-) diff --git a/astro.config.ts b/astro.config.ts index 44248d5..6a75b72 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -71,7 +71,7 @@ export default defineConfig({ }, vite: { // Add this for avoiding the needless import optimize in Vite. - optimizeDeps: { exclude: ['@napi-rs/canvas', 'opendal'] }, + optimizeDeps: { exclude: ['@napi-rs/canvas', 'opendal', 'sharp'] }, }, build: { assets: 'cats', diff --git a/options.ts b/options.ts index fd27e81..b4bedbe 100644 --- a/options.ts +++ b/options.ts @@ -177,7 +177,7 @@ const options: z.input = { category: ['article', 'think', 'gossip', 'coding'], }, pagination: { - posts: 5, + posts: 6, category: 7, tags: 7, search: 7, diff --git a/package-lock.json b/package-lock.json index 94b1939..3b9e367 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@astrojs/mdx": "^3.1.9", "@astrojs/rss": "^4.0.9", "@zeabur/astro-adapter": "^1.0.6", - "astro": "^4.16.14", + "astro": "^4.16.15", "drizzle-orm": "^0.36.4", "fuse.js": "^7.0.0", "lodash": "^4.17.21", @@ -20,6 +20,7 @@ "marked": "^15.0.2", "pg": "^8.13.1", "qrcode-svg": "^1.1.0", + "sharp": "^0.33.5", "ultrahtml": "^1.5.3" }, "devDependencies": { @@ -35,7 +36,7 @@ "aplayer": "^1.10.1", "astro-uploader": "^1.1.3", "bootstrap": "^5.3.3", - "prettier": "^3.4.0", + "prettier": "^3.4.1", "prettier-plugin-astro": "^0.14.1", "prettier-plugin-astro-organize-imports": "^0.4.11", "prettier-plugin-organize-imports": "^4.1.0", @@ -44,7 +45,6 @@ "rehype-slug": "^6.0.0", "resize-sensor": "^0.0.6", "rimraf": "^6.0.1", - "sharp": "^0.33.5", "typescript": "^5.7.2", "unist-util-select": "^5.1.0" }, @@ -760,7 +760,6 @@ "version": "1.3.1", "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.3.1.tgz", "integrity": "sha512-kEBmG8KyqtxJZv+ygbEim+KCGtIq1fC22Ms3S4ziXmYKm8uyoLX0MHONVKwp+9opg390VaKRNt4a7A9NwmpNhw==", - "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -1142,7 +1141,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "Apache-2.0", "optional": true, "os": [ @@ -1165,7 +1163,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "Apache-2.0", "optional": true, "os": [ @@ -1188,7 +1185,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1205,7 +1201,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1222,7 +1217,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1239,7 +1233,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1256,7 +1249,6 @@ "cpu": [ "s390x" ], - "dev": true, "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1273,7 +1265,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1290,7 +1281,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1307,7 +1297,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1324,7 +1313,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "Apache-2.0", "optional": true, "os": [ @@ -1347,7 +1335,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "Apache-2.0", "optional": true, "os": [ @@ -1370,7 +1357,6 @@ "cpu": [ "s390x" ], - "dev": true, "license": "Apache-2.0", "optional": true, "os": [ @@ -1393,7 +1379,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "Apache-2.0", "optional": true, "os": [ @@ -1416,7 +1401,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "Apache-2.0", "optional": true, "os": [ @@ -1439,7 +1423,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "Apache-2.0", "optional": true, "os": [ @@ -1462,7 +1445,6 @@ "cpu": [ "wasm32" ], - "dev": true, "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", "optional": true, "dependencies": { @@ -1482,7 +1464,6 @@ "cpu": [ "ia32" ], - "dev": true, "license": "Apache-2.0 AND LGPL-3.0-or-later", "optional": true, "os": [ @@ -1502,7 +1483,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "Apache-2.0 AND LGPL-3.0-or-later", "optional": true, "os": [ @@ -2907,9 +2887,9 @@ } }, "node_modules/astro": { - "version": "4.16.14", - "resolved": "https://registry.npmjs.org/astro/-/astro-4.16.14.tgz", - "integrity": "sha512-2IuLkIp4idyspugq+F52rHZyNqHHi2AdQzuKp3SGytg/YAm50dNeWhP/7l+enjgWZLloLq5xsH5gVQpoDFoyFg==", + "version": "4.16.15", + "resolved": "https://registry.npmjs.org/astro/-/astro-4.16.15.tgz", + "integrity": "sha512-usybZ7nEUiwYKT7r47l4VbkqjKfaE+BgWV/ed4PT3mE3vFRTBWFsXLnkzrN7awfN6+/ekZTAcE+MAkdA551Umw==", "license": "MIT", "dependencies": { "@astrojs/compiler": "^2.10.3", @@ -3535,7 +3515,6 @@ "version": "4.2.3", "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==", - "devOptional": true, "license": "MIT", "dependencies": { "color-convert": "^2.0.1", @@ -3549,7 +3528,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "devOptional": true, "license": "MIT", "dependencies": { "color-name": "~1.1.4" @@ -3562,14 +3540,12 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "devOptional": true, "license": "MIT" }, "node_modules/color-string": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz", "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==", - "devOptional": true, "license": "MIT", "dependencies": { "color-name": "^1.0.0", @@ -4950,7 +4926,6 @@ "version": "0.3.2", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==", - "devOptional": true, "license": "MIT" }, "node_modules/is-decimal": { @@ -6549,9 +6524,9 @@ "license": "MIT" }, "node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", + "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==", "funding": [ { "type": "github", @@ -7276,9 +7251,9 @@ } }, "node_modules/prettier": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.4.0.tgz", - "integrity": "sha512-/OXNZcLyWkfo13ofOW5M7SLh+k5pnIs07owXK2teFpnfaOEcycnSy7HQxldaVX1ZP/7Q8oO1eDuQJNwbomQq5Q==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.4.1.tgz", + "integrity": "sha512-G+YdqtITVZmOJje6QkXQWzl3fSfMxFwm1tjTyo9exhkmWSqC4Yhd1+lug++IlR2mvRVAxEDDWYkQdeSztajqgg==", "dev": true, "license": "MIT", "bin": { @@ -8169,7 +8144,6 @@ "version": "0.33.5", "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.33.5.tgz", "integrity": "sha512-haPVm1EkS9pgvHrQ/F3Xy+hgcuMV0Wm9vfIBSiwZ05k+xgb0PkBQpGsAA/oWdDobNaZTH5ppvHtzCFbnSEwHVw==", - "devOptional": true, "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -8252,7 +8226,6 @@ "version": "0.2.2", "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==", - "devOptional": true, "license": "MIT", "dependencies": { "is-arrayish": "^0.3.1" @@ -8576,14 +8549,13 @@ "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "dev": true, "license": "0BSD", "optional": true }, "node_modules/type-fest": { - "version": "4.28.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.28.0.tgz", - "integrity": "sha512-jXMwges/FVbFRe5lTMJZVEZCrO9kI9c8k0PA/z7nF3bo0JSCCLysvokFjNPIUK/itEMas10MQM+AiHoHt/T/XA==", + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.28.1.tgz", + "integrity": "sha512-LO/+yb3mf46YqfUC7QkkoAlpa7CTYh//V1Xy9+NQ+pKqDqXIq0NTfPfQRwFfCt+if4Qkwb9gzZfsl6E5TkXZGw==", "license": "(MIT OR CC0-1.0)", "engines": { "node": ">=16" @@ -8946,16 +8918,16 @@ } }, "node_modules/vitefu": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.0.3.tgz", - "integrity": "sha512-iKKfOMBHob2WxEJbqbJjHAkmYgvFDPhuqrO82om83S8RLk+17FtyMBfcyeH8GqD0ihShtkMW/zzJgiA51hCNCQ==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.0.4.tgz", + "integrity": "sha512-y6zEE3PQf6uu/Mt6DTJ9ih+kyJLr4XcSgHR2zUkM8SWDhuixEJxfJ6CZGMHh1Ec3vPLoEA0IHU5oWzVqw8ulow==", "license": "MIT", "workspaces": [ "tests/deps/*", "tests/projects/*" ], "peerDependencies": { - "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0-beta.0" + "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0" }, "peerDependenciesMeta": { "vite": { diff --git a/package.json b/package.json index 9899fbb..6c90492 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@astrojs/mdx": "^3.1.9", "@astrojs/rss": "^4.0.9", "@zeabur/astro-adapter": "^1.0.6", - "astro": "^4.16.14", + "astro": "^4.16.15", "drizzle-orm": "^0.36.4", "fuse.js": "^7.0.0", "lodash": "^4.17.21", @@ -53,6 +53,7 @@ "marked": "^15.0.2", "pg": "^8.13.1", "qrcode-svg": "^1.1.0", + "sharp": "^0.33.5", "ultrahtml": "^1.5.3" }, "devDependencies": { @@ -68,7 +69,7 @@ "aplayer": "^1.10.1", "astro-uploader": "^1.1.3", "bootstrap": "^5.3.3", - "prettier": "^3.4.0", + "prettier": "^3.4.1", "prettier-plugin-astro": "^0.14.1", "prettier-plugin-astro-organize-imports": "^0.4.11", "prettier-plugin-organize-imports": "^4.1.0", @@ -77,7 +78,6 @@ "rehype-slug": "^6.0.0", "resize-sensor": "^0.0.6", "rimraf": "^6.0.1", - "sharp": "^0.33.5", "typescript": "^5.7.2", "unist-util-select": "^5.1.0" }, diff --git a/src/components/sidebar/OwspaceCalendar.astro b/src/components/sidebar/OwspaceCalendar.astro index b71e96c..181d199 100644 --- a/src/components/sidebar/OwspaceCalendar.astro +++ b/src/components/sidebar/OwspaceCalendar.astro @@ -1,6 +1,7 @@ --- import options from '@/options'; import { DateTime } from 'luxon'; +import sharp from 'sharp'; const loadCalendarImage = async (): Promise => { const now = DateTime.now().setZone(options.settings.timeZone); @@ -14,7 +15,11 @@ const loadCalendarImage = async (): Promise => { return ''; } - const encodedImage = Buffer.from(await response.arrayBuffer()).toString('base64'); + const encodedImage = ( + await sharp(await response.arrayBuffer()) + .extract({ width: 1096, height: 1550, left: 90, top: 110 }) + .toBuffer() + ).toString('base64'); return `data:image/jpeg;base64,${encodedImage}`; }; @@ -24,6 +29,7 @@ const calendarImage = !options.settings.sidebar.calendar ? '' : await loadCalend { calendarImage !== '' && (
+
单向历
) diff --git a/src/components/sidebar/RandomPosts.astro b/src/components/sidebar/RandomPosts.astro index 36ac939..1b23327 100644 --- a/src/components/sidebar/RandomPosts.astro +++ b/src/components/sidebar/RandomPosts.astro @@ -14,7 +14,7 @@ const randomSize = options.settings.sidebar.post; { randomSize > 0 && ( -
+
随机文章
    {_.sampleSize(posts, randomSize).map((post) => ( diff --git a/src/components/sidebar/RandomTags.astro b/src/components/sidebar/RandomTags.astro index 1a3403f..6220700 100644 --- a/src/components/sidebar/RandomTags.astro +++ b/src/components/sidebar/RandomTags.astro @@ -14,7 +14,7 @@ const randomSize = options.settings.sidebar.tag; { randomSize > 0 && ( -
    +
    文章标签
    {_.sampleSize(tags, randomSize).map((tag) => (