From c3ac2c962d425571cebd3f1752c49cef64982810 Mon Sep 17 00:00:00 2001 From: grassblock Date: Fri, 15 Aug 2025 17:07:10 +0800 Subject: [PATCH 1/6] fix: overflow when there are a lot of items on small screens --- src/styles/global.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/styles/global.css b/src/styles/global.css index 7202d96..9b0cc3f 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -103,6 +103,7 @@ body { .nav { display: flex; + flex-wrap: wrap; gap: 2rem; margin: 1.5rem 0; } From 4a463d279465b3f3dc8a747705e70302430c4a2d Mon Sep 17 00:00:00 2001 From: grassblock Date: Fri, 15 Aug 2025 17:27:08 +0800 Subject: [PATCH 2/6] feat: responsive images --- astro.config.mjs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/astro.config.mjs b/astro.config.mjs index d9390d4..7ffed49 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -37,6 +37,11 @@ export default defineConfig({ rehypePlugins: [rehypeKatex] }, + image: { + responsiveStyles: true, + layouts: 'constrained', + }, + i18n: { locales: ["en", "zh_hans"], defaultLocale: "en", From 15846c0089c812e5b0e61475a19045c6934647dc Mon Sep 17 00:00:00 2001 From: grassblock Date: Fri, 15 Aug 2025 17:30:41 +0800 Subject: [PATCH 3/6] fix: wrong description for homepage --- src/layouts/Layout.astro | 4 ++-- src/pages/index.astro | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index f47600a..e1b69fd 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -11,8 +11,8 @@ import Statistics from "../components/Statistics.astro"; import Navbar from "../components/Navbar.astro"; interface Props { - title: string; - description: string; + title?: string; + description?: string; author?: string; path?: string; ogImage?: string; diff --git a/src/pages/index.astro b/src/pages/index.astro index 5cf2089..c04253a 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -12,7 +12,7 @@ try { } --- - +

~/

{HomePageContent ? : From 112f76dae1ee39cbef0b18ab57cd048aebfe1425 Mon Sep 17 00:00:00 2001 From: grassblock Date: Fri, 15 Aug 2025 17:40:32 +0800 Subject: [PATCH 4/6] fix: author custom avatar not displayed --- src/components/helper/authors/Info.astro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/helper/authors/Info.astro b/src/components/helper/authors/Info.astro index 4155f11..f660050 100644 --- a/src/components/helper/authors/Info.astro +++ b/src/components/helper/authors/Info.astro @@ -5,7 +5,7 @@ import {siteConfig} from "../../../config"; const { data } = Astro.props; // Get author data -const authorAvatar = data.mcplayerid ? `/images/avatars/${data.mcplayerid}.png` : null; +const authorAvatar = data.mcplayerid ? `/images/avatars/${data.mcplayerid}.png` : (data.avatar ? data.avatar : null); const authorName = data.name ? data.name : null; --- {(siteConfig.displayAvatar && data) && From daa3df13ada782f7c447ff5e1d4fc92eccf92393 Mon Sep 17 00:00:00 2001 From: grassblock Date: Fri, 15 Aug 2025 17:45:30 +0800 Subject: [PATCH 5/6] fix: author default avatar path returns 404 --- src/pages/images/avatars/[author].png.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pages/images/avatars/[author].png.js b/src/pages/images/avatars/[author].png.js index df69c22..b449d56 100644 --- a/src/pages/images/avatars/[author].png.js +++ b/src/pages/images/avatars/[author].png.js @@ -66,7 +66,7 @@ async function cacheAvatar(cacheKey, data) { } function addToMemoryCache(key, data) { - // If cache is full, remove oldest entry + // If cache is full, remove the oldest entry if (AVATAR_CACHE.size >= CACHE_MAX_SIZE) { const oldestKey = AVATAR_CACHE.keys().next().value; AVATAR_CACHE.delete(oldestKey); @@ -80,10 +80,12 @@ function addToMemoryCache(key, data) { export async function getStaticPaths() { const authorsData = await getCollection('authors'); - return authorsData.map(author => ({ - params: { author: author.id }, - props: { author } - })); + return authorsData + .filter(author => author.data.mcplayerid) // Only include authors with mcplayerid + .map(author => ({ + params: { author: author.data.mcplayerid }, + props: { author } + })); } export async function GET({ props }) { From ee714021e6b0210aa7a9d53c5c13adbb1b913af6 Mon Sep 17 00:00:00 2001 From: grassblock Date: Fri, 15 Aug 2025 18:39:39 +0800 Subject: [PATCH 6/6] chore(docs): update README.md --- README.md | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9483f72..f497770 100644 --- a/README.md +++ b/README.md @@ -70,11 +70,48 @@ All commands are run from the root of the project, from a terminal: - [x] Better support for printing version - [ ] Add support for more comment engines - [x] Add support for umami statics -- [ ] Improve documentation +- [x] Improve documentation - [ ] Release v1.0 - [ ] ~~Integrate with Fediverse w/ activityPub~~ - [ ] ~~Plain text version when visiting the site via `curl`~~ (can't be done with SSG mode) +## ⚙️ Advanced Usage +### i18n +I have implemented i18n support for UI text, but not for content translations yet. + +To further implement i18n, you can: +1. Create a new folder under `src/content/posts/` with the language code as the name (e.g., `en`, `zh-CN`, etc.). +2. Copy your translated markdown files into the new folder. +3. Copy the `src/pages/blog/` folder to `src/pages/[langcode]/blog`. +4. Update the i18n config in `astro.config.mjs` to include the new language code. +5. Rebuild the site. +### plain text version when visiting the site via `curl` +The text version of the site is generated by `src/pages/blog/[slug].txt.js`, which outputs a plain text version of the blog post. +To access it, you can visit `https://your-site.com/blog/your-post-slug.txt`. + +To automatically output the text version when visiting the site via `curl`, you can: +1. If you are using caddy, add the following to your `Caddyfile`: + ```caddyfile + @curl { + header_regexp User-Agent (?i)curl + } + @text { + path_regexp text /blog/(.*) + } + handle @curl { + rewrite @text /blog/{http.regexp.text.1}.txt + } + ``` +2. If you are using cloudflare to proxy your site, you can add a page rule to redirect requests with the `curl` user agent to the `.txt` version of the blog post: + If incoming requests match (Custom filter expression): + ``` + (http.request.full_uri wildcard r"https://yourblog/blog/*" and http.user_agent contains "curl") + ``` + Then (Rewrite to,static): + ``` + /blog/${1}.txt + ``` +3. If you are using other web servers, you can use functions like `rewrite` or `redirect` by user agent (HTTP header) to achieve the same effect. ## 👀 Want to learn more? See the post [🕊](). I hope you like it. 💜 @@ -88,6 +125,6 @@ Other tools like GitHub Copilot helps too. (I know the LLMs sometimes sucks, but it really helps most of the time) -Also [delucis/astro-blog-full-text-rss](https://github.com/delucis/astro-blog-full-text-rss) for implementing full text RSS in pretty easy way +Also, [delucis/astro-blog-full-text-rss](https://github.com/delucis/astro-blog-full-text-rss) for implementing full text RSS in pretty easy way. ## ⚖️ License GNU Affero Public License 3.0 \ No newline at end of file