Compare commits

..

7 Commits

Author SHA1 Message Date
d2622ac85b Upgrade dependencies. 2025-12-04 23:26:55 +08:00
4ab4cc39d2 Add extra space on both sides. 2025-10-11 21:35:53 +08:00
7be5057d5b Upgrade dependencies. 2025-09-23 15:29:42 +08:00
bc19f9a638 Upgrade dependencies. 2025-03-18 21:13:45 +08:00
498fa8519e Use nvm to activate node in build scrpit. 2025-01-07 10:01:22 +08:00
e7f6738a27 Remove nodejs path from $PATH. 2024-11-10 22:40:42 +08:00
036d98dbd4 Update article license. 2024-10-27 13:17:29 +08:00
15 changed files with 3619 additions and 3209 deletions

View File

@@ -1,7 +1,8 @@
import { z, defineCollection } from 'astro:content'; import { z, defineCollection } from 'astro:content';
import { glob } from 'astro/loaders';
const blogCollection = defineCollection({ const blogCollection = defineCollection({
type: 'content', loader: glob({ pattern: '**/[^_]*.{md,mdx}', base: "./src/content/blog" }),
schema: z.object({ schema: z.object({
title: z.string(), title: z.string(),
description: z.string(), description: z.string(),
@@ -10,7 +11,7 @@ const blogCollection = defineCollection({
}), }),
}); });
const noteCollection = defineCollection({ const noteCollection = defineCollection({
type: 'content', loader: glob({ pattern: '**/[^_]*.{md,mdx}', base: "./src/content/note" }),
schema: z.object({ schema: z.object({
title: z.string(), title: z.string(),
description: z.string(), description: z.string(),
@@ -19,7 +20,7 @@ const noteCollection = defineCollection({
}), }),
}); });
const translationCollection = defineCollection({ const translationCollection = defineCollection({
type: 'content', loader: glob({ pattern: '**/[^_]*.{md,mdx}', base: "./src/content/translation" }),
schema: z.object({ schema: z.object({
title: z.string(), title: z.string(),
description: z.string(), description: z.string(),
@@ -32,4 +33,4 @@ export const collections = {
'blog': blogCollection, 'blog': blogCollection,
'note': noteCollection, 'note': noteCollection,
'translation': translationCollection, 'translation': translationCollection,
}; };

6686
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,23 +3,23 @@
"type": "module", "type": "module",
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"dev": "astro dev", "dev": "astro dev --host",
"start": "astro dev", "start": "astro dev --host",
"build": "astro check && astro build", "build": "astro check && astro build",
"preview": "astro preview", "preview": "astro preview",
"astro": "astro" "astro": "astro"
}, },
"dependencies": { "dependencies": {
"@astrojs/check": "^0.7.0", "@astrojs/check": "^0.9.4",
"@astrojs/sitemap": "^3.1.5", "@astrojs/sitemap": "^3.6.0",
"@astrojs/vue": "^4.5.0", "@astrojs/vue": "^5.1.3",
"astro": "^4.9.2", "astro": "^5.15.9",
"bignumber.js": "^9.1.2", "bignumber.js": "^9.3.1",
"pinyin-pro": "^3.22.0", "pinyin-pro": "^3.27.0",
"prettier": "^3.3.3", "prettier": "^3.7.4",
"prettier-plugin-astro": "^0.14.1", "prettier-plugin-astro": "^0.14.1",
"remark-toc": "^9.0.0", "remark-toc": "^9.0.0",
"typescript": "^5.4.5", "typescript": "^5.8.2",
"vue": "^3.4.29" "vue": "^3.5.13"
} }
} }

View File

@@ -2,7 +2,8 @@
# cron # cron
# 0 4 * * * . /etc/profile; /bin/sh /opt/ld-site/script/build_on_linux.sh >/dev/null 2>&1 # 0 4 * * * . /etc/profile; /bin/sh /opt/ld-site/script/build_on_linux.sh >/dev/null 2>&1
export PATH=$PATH:/opt/dev_tools/node-v20.12.2-linux-x64/bin NVM_DIR="/opt/dev_tools/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
script_path="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" script_path="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
original_article_home="/home/ld/Documents/ld_article" original_article_home="/home/ld/Documents/ld_article"

View File

@@ -11,8 +11,8 @@
<div> <div>
<small class="licence">若正文中无特殊说明,本站内容遵循:</small> <small class="licence">若正文中无特殊说明,本站内容遵循:</small>
<small class="licence"> <small class="licence">
<a href="http://creativecommons.org/licenses/by-nc-sa/4.0/"> <a href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank">
署名-非商业使用-相同方式共享 4.0 国际许可 署名-非商业使用 4.0 协议国际版
</a> </a>
</small> </small>
</div> </div>

View File

@@ -14,7 +14,8 @@ const { collectionName, categoryName, posts } = Astro.props;
{ {
posts.map((post) => ( posts.map((post) => (
<li> <li>
<a href={`/article/${collectionName}/${post.slug}`} target="_blank"> {/* Hide .md extension from URL */}
<a href={`/article/${collectionName}/${post.id.replace(".md", "")}`} target="_blank">
{post.data.title} {post.data.title}
</a> </a>
</li> </li>

View File

@@ -1,5 +1,5 @@
--- ---
import type { CollectionEntry, ContentEntryMap } from "astro:content"; import type { CollectionEntry } from "astro:content";
import { getCollection, type CollectionKey } from "astro:content"; import { getCollection, type CollectionKey } from "astro:content";
import CategorySummary from "./CategorySummary.astro"; import CategorySummary from "./CategorySummary.astro";
@@ -57,9 +57,9 @@ const categoriedPostList: Array<CategoriedPosts> = allCategories.map((key) => {
} else if (sortByArticleTitle) { } else if (sortByArticleTitle) {
// sort article by title // sort article by title
// get articles with titles started in Chinese or the alphabet // get articles with titles started in Chinese or the alphabet
let postWithAlphabetStartedTitle: CollectionEntry<keyof ContentEntryMap>[] = let postWithAlphabetStartedTitle: CollectionEntry<CollectionKey>[] =
object[key].filter((post) => /^[a-zA-Z]/.test(post.data.title)); object[key].filter((post) => /^[a-zA-Z]/.test(post.data.title));
let postWithChineseStartedTitle: CollectionEntry<keyof ContentEntryMap>[] = let postWithChineseStartedTitle: CollectionEntry<CollectionKey>[] =
object[key].filter((post) => /^[^a-zA-Z]/.test(post.data.title)); object[key].filter((post) => /^[^a-zA-Z]/.test(post.data.title));
// sort two Array by article title // sort two Array by article title
postWithAlphabetStartedTitle.sort((postA, postB) => postWithAlphabetStartedTitle.sort((postA, postB) =>

View File

@@ -1,15 +1,19 @@
--- ---
import { getEntry, type CollectionKey } from "astro:content"; import { getCollection, type CollectionEntry } from "astro:content";
import { render, type CollectionKey } from "astro:content";
interface Props { interface Props {
articleSlug: string; articleId: string;
collectionName: CollectionKey; collectionName: CollectionKey;
} }
const { articleSlug, collectionName } = Astro.props; const { articleId, collectionName } = Astro.props;
const article = await getEntry(collectionName, articleSlug); const articles = await getCollection(collectionName);
const { Content } = await article!.render(); const article = articles.find(
const articlePrettyName = article!.id.split("/").pop()!.replace(".md", ""); (post: CollectionEntry<CollectionKey>) => post.id === articleId
);
const { Content } = await render(article!);
const articlePrettyName = article!.data.title;
--- ---
<div class="article"> <div class="article">

View File

@@ -4,15 +4,15 @@ import ArticleBody from "./ArticleBody.astro";
import ArticleBodyContent from "./ArticleBodyContent.astro"; import ArticleBodyContent from "./ArticleBodyContent.astro";
interface Props { interface Props {
articleSlug: string; articleId: string;
collectionName: CollectionKey; collectionName: CollectionKey;
} }
const { articleSlug, collectionName } = Astro.props; const { articleId, collectionName } = Astro.props;
--- ---
<ArticleBody> <ArticleBody>
<ArticleBodyContent <ArticleBodyContent
articleId={articleId}
collectionName={collectionName} collectionName={collectionName}
articleSlug={articleSlug}
/> />
</ArticleBody> </ArticleBody>

View File

@@ -7,6 +7,6 @@ import ArticleBodyWrapper from "../components/article/article_body/ArticleBodyWr
<DefaultLayout title="404"> <DefaultLayout title="404">
<Nav /> <Nav />
<ArticleBodyWrapper collectionName="site" articleSlug="404" /> <ArticleBodyWrapper collectionName="site" articleId="404.md" />
<Footer /> <Footer />
</DefaultLayout> </DefaultLayout>

View File

@@ -1,10 +1,6 @@
--- ---
import { getCollection } from "astro:content"; import { getCollection } from "astro:content";
import type { import type { CollectionEntry, CollectionKey } from "astro:content";
CollectionEntry,
CollectionKey,
ContentEntryMap,
} from "astro:content";
import Footer from "../../../components/Footer.astro"; import Footer from "../../../components/Footer.astro";
import Nav from "../../../components/Nav.astro"; import Nav from "../../../components/Nav.astro";
import ArticleBodyWrapper from "../../../components/article/article_body/ArticleBodyWrapper.astro"; import ArticleBodyWrapper from "../../../components/article/article_body/ArticleBodyWrapper.astro";
@@ -13,22 +9,23 @@ import DefaultLayout from "../../../layouts/DefaultLayout.astro";
export async function getStaticPaths() { export async function getStaticPaths() {
const collectionName: CollectionKey = "blog"; const collectionName: CollectionKey = "blog";
const blogEntries = await getCollection(collectionName); const blogEntries = await getCollection(collectionName);
return blogEntries.map((entry) => ({ return blogEntries.map((post: CollectionEntry<CollectionKey>) => ({
params: { blog: entry.slug }, // Hide .md extension from URL
props: { entry }, params: { blog: post.id.replace(".md", "") },
props: { post },
})); }));
} }
interface Props { interface Props {
entry: CollectionEntry<keyof ContentEntryMap>; post: CollectionEntry<CollectionKey>;
} }
const { entry } = Astro.props; const { post } = Astro.props;
const articlePrettyName: string = entry.id.split("/").pop()!.replace(".md", ""); const articlePrettyName: string = post.data.title;
--- ---
<DefaultLayout title=`${articlePrettyName} - 李守中`> <DefaultLayout title=`${articlePrettyName} - 李守中`>
<Nav /> <Nav />
<ArticleBodyWrapper collectionName="blog" articleSlug={entry.slug} /> <ArticleBodyWrapper collectionName="blog" articleId={post.id} />
<Footer /> <Footer />
</DefaultLayout> </DefaultLayout>

View File

@@ -1,10 +1,6 @@
--- ---
import { getCollection } from "astro:content"; import { getCollection } from "astro:content";
import type { import type { CollectionEntry, CollectionKey } from "astro:content";
CollectionEntry,
CollectionKey,
ContentEntryMap,
} from "astro:content";
import Footer from "../../../components/Footer.astro"; import Footer from "../../../components/Footer.astro";
import Nav from "../../../components/Nav.astro"; import Nav from "../../../components/Nav.astro";
import ArticleBodyWrapper from "../../../components/article/article_body/ArticleBodyWrapper.astro"; import ArticleBodyWrapper from "../../../components/article/article_body/ArticleBodyWrapper.astro";
@@ -13,22 +9,22 @@ import DefaultLayout from "../../../layouts/DefaultLayout.astro";
export async function getStaticPaths() { export async function getStaticPaths() {
const collectionName: CollectionKey = "note"; const collectionName: CollectionKey = "note";
const blogEntries = await getCollection(collectionName); const blogEntries = await getCollection(collectionName);
return blogEntries.map((entry) => ({ return blogEntries.map((post: CollectionEntry<CollectionKey>) => ({
params: { note: entry.slug }, params: { note: post.id.replace(".md", "") },
props: { entry }, props: { post },
})); }));
} }
interface Props { interface Props {
entry: CollectionEntry<keyof ContentEntryMap>; post: CollectionEntry<CollectionKey>;
} }
const { entry } = Astro.props; const { post } = Astro.props;
const articlePrettyName: string = entry.id.split("/").pop()!.replace(".md", ""); const articlePrettyName: string = post.data.title;
--- ---
<DefaultLayout title=`${articlePrettyName} - 李守中`> <DefaultLayout title=`${articlePrettyName} - 李守中`>
<Nav /> <Nav />
<ArticleBodyWrapper collectionName="note" articleSlug={entry.slug} /> <ArticleBodyWrapper collectionName="note" articleId={post.id} />
<Footer /> <Footer />
</DefaultLayout> </DefaultLayout>

View File

@@ -7,6 +7,6 @@ import ArticleBodyWrapper from "../components/article/article_body/ArticleBodyWr
<DefaultLayout title="李守中"> <DefaultLayout title="李守中">
<Nav /> <Nav />
<ArticleBodyWrapper collectionName="site" articleSlug="关于本站" /> <ArticleBodyWrapper collectionName="site" articleId="关于本站.md" />
<Footer /> <Footer />
</DefaultLayout> </DefaultLayout>

View File

@@ -18,21 +18,21 @@ body {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
font-family: font-family:
"Consolas", "Consolas",
"Hack", "Hack",
Tahoma, Tahoma,
Arial, Arial,
"Hiragino Sans GB", "Hiragino Sans GB",
"Microsoft YaHei", "Microsoft YaHei",
"WenQuanYi Micro Hei", "WenQuanYi Micro Hei",
sans-serif, sans-serif,
"Apple Color Emoji", "Apple Color Emoji",
"Segoe UI Emoji", "Segoe UI Emoji",
"Segoe UI Symbol", "Segoe UI Symbol",
"Noto Color Emoji"; "Noto Color Emoji";
font-size: 1em; font-size: 1em;
margin: auto; margin: auto;
overflow-y: scroll; padding: 0 8px 0 8px;
min-height: 100%; min-height: 100%;
line-height: 1.5; line-height: 1.5;
} }

View File

@@ -1,5 +1,7 @@
{ {
"extends": "astro/tsconfigs/strict", "extends": "astro/tsconfigs/strict",
"include": [".astro/types.d.ts", "**/*"],
"exclude": ["dist"],
"compilerOptions": { "compilerOptions": {
"jsx": "preserve" "jsx": "preserve"
} }