Compare commits

..

No commits in common. "ee714021e6b0210aa7a9d53c5c13adbb1b913af6" and "30b0738af0471a375cf5f305fda9ae7293355e9a" have entirely different histories.

7 changed files with 11 additions and 56 deletions

View file

@ -70,48 +70,11 @@ All commands are run from the root of the project, from a terminal:
- [x] Better support for printing version - [x] Better support for printing version
- [ ] Add support for more comment engines - [ ] Add support for more comment engines
- [x] Add support for umami statics - [x] Add support for umami statics
- [x] Improve documentation - [ ] Improve documentation
- [ ] Release v1.0 - [ ] Release v1.0
- [ ] ~~Integrate with Fediverse w/ activityPub~~ - [ ] ~~Integrate with Fediverse w/ activityPub~~
- [ ] ~~Plain text version when visiting the site via `curl`~~ (can't be done with SSG mode) - [ ] ~~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? ## 👀 Want to learn more?
See the post [🕊](). I hope you like it. 💜 See the post [🕊](). I hope you like it. 💜
@ -125,6 +88,6 @@ Other tools like GitHub Copilot helps too.
(I know the LLMs sometimes sucks, but it really helps most of the time) (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 ## ⚖️ License
GNU Affero Public License 3.0 GNU Affero Public License 3.0

View file

@ -37,11 +37,6 @@ export default defineConfig({
rehypePlugins: [rehypeKatex] rehypePlugins: [rehypeKatex]
}, },
image: {
responsiveStyles: true,
layouts: 'constrained',
},
i18n: { i18n: {
locales: ["en", "zh_hans"], locales: ["en", "zh_hans"],
defaultLocale: "en", defaultLocale: "en",

View file

@ -5,7 +5,7 @@ import {siteConfig} from "../../../config";
const { data } = Astro.props; const { data } = Astro.props;
// Get author data // Get author data
const authorAvatar = data.mcplayerid ? `/images/avatars/${data.mcplayerid}.png` : (data.avatar ? data.avatar : null); const authorAvatar = data.mcplayerid ? `/images/avatars/${data.mcplayerid}.png` : null;
const authorName = data.name ? data.name : null; const authorName = data.name ? data.name : null;
--- ---
{(siteConfig.displayAvatar && data) && {(siteConfig.displayAvatar && data) &&

View file

@ -11,8 +11,8 @@ import Statistics from "../components/Statistics.astro";
import Navbar from "../components/Navbar.astro"; import Navbar from "../components/Navbar.astro";
interface Props { interface Props {
title?: string; title: string;
description?: string; description: string;
author?: string; author?: string;
path?: string; path?: string;
ogImage?: string; ogImage?: string;

View file

@ -66,7 +66,7 @@ async function cacheAvatar(cacheKey, data) {
} }
function addToMemoryCache(key, data) { function addToMemoryCache(key, data) {
// If cache is full, remove the oldest entry // If cache is full, remove oldest entry
if (AVATAR_CACHE.size >= CACHE_MAX_SIZE) { if (AVATAR_CACHE.size >= CACHE_MAX_SIZE) {
const oldestKey = AVATAR_CACHE.keys().next().value; const oldestKey = AVATAR_CACHE.keys().next().value;
AVATAR_CACHE.delete(oldestKey); AVATAR_CACHE.delete(oldestKey);
@ -80,12 +80,10 @@ function addToMemoryCache(key, data) {
export async function getStaticPaths() { export async function getStaticPaths() {
const authorsData = await getCollection('authors'); const authorsData = await getCollection('authors');
return authorsData return authorsData.map(author => ({
.filter(author => author.data.mcplayerid) // Only include authors with mcplayerid params: { author: author.id },
.map(author => ({ props: { author }
params: { author: author.data.mcplayerid }, }));
props: { author }
}));
} }
export async function GET({ props }) { export async function GET({ props }) {

View file

@ -12,7 +12,7 @@ try {
} }
--- ---
<Layout> <Layout title="" description="That a good start.">
<h1 class="title">~/</h1> <h1 class="title">~/</h1>
<div class="content"> <div class="content">
{HomePageContent ? <HomePageContent/> : {HomePageContent ? <HomePageContent/> :

View file

@ -103,7 +103,6 @@ body {
.nav { .nav {
display: flex; display: flex;
flex-wrap: wrap;
gap: 2rem; gap: 2rem;
margin: 1.5rem 0; margin: 1.5rem 0;
} }