From 8b07e121a56f1c878e69e244616589ce02155646 Mon Sep 17 00:00:00 2001 From: liding Date: Sun, 13 Oct 2024 15:45:34 +0800 Subject: [PATCH] Migrate translation article source code format to texinfo. --- .gitignore | 4 + README.md | 11 ++ astro.config.mjs | 19 ++- script/build_on_linux.sh | 14 +- .../translation/[...translation].astro | 34 ---- src/pages/article/translation/index.astro | 153 ++++++++++++++++-- .../translation/sort_by_timeline.astro | 37 ----- 7 files changed, 189 insertions(+), 83 deletions(-) delete mode 100644 src/pages/article/translation/[...translation].astro delete mode 100644 src/pages/article/translation/sort_by_timeline.astro diff --git a/.gitignore b/.gitignore index 82799e1..c6b18d7 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,7 @@ pnpm-debug.log* # ignore test articles except for article definitions src/content/* !src/content/config.ts + +# ignore generated html from makeinfo +src/pages/article/translation/*.html + diff --git a/README.md b/README.md index ff1fabe..69d495e 100644 --- a/README.md +++ b/README.md @@ -1 +1,12 @@ +# 李守中的个人站 + 个人资料、文章与工具站点。由 Astro 框架构建,使用 typescript 编写。 + +## 关于翻译类文章的发布方式 + +翻译类文章不由 Astro 生成,而是预先使用 texinfo 编写后编译到 HTML 文件,将其放于固定位置,再在 Astro 页面中引用这些文件。 + +这意味着每有一个新的翻译类文章要发布时,需要: + +1. 更新 pages/article/translation/index.astro 文件中翻译类文章的列表; +2. 更新 astro.config.mjs 文件中的 sitemap 插件配置,填入 texinfo 编译出的 HTML 文件的 URL 以使这些文章可以进入 sitemap.xml 中,从而可以被搜索引擎收录。 diff --git a/astro.config.mjs b/astro.config.mjs index 0478374..d78845f 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -35,8 +35,25 @@ export default defineConfig({ site: 'https://lishouzhong.com', integrations: [ sitemap({ + customPages: [ + "https://lishouzhong.com/file_share/translation/FreeBSD 13 NFS exports man(5) page 2021 中文译本.html", + "https://lishouzhong.com/file_share/translation/FreeBSD 13 NFS mountd man(8) page 2020 中文译本.html", + "https://lishouzhong.com/file_share/translation/FreeBSD 13 NFS nfsd man(8) page 2019 中文译本.html", + "https://lishouzhong.com/file_share/translation/FreeBSD 13 NFS showmount man(8) page 2016 中文译本.html", + "https://lishouzhong.com/file_share/translation/FreeBSD 13 NFSv4 man(4) page 2019 中文译本.html", + "https://lishouzhong.com/file_share/translation/FreeBSD 13 NFSv4 nfscbd man(8) page 2009 中文译本.html", + "https://lishouzhong.com/file_share/translation/FreeBSD 13 NFSv4 nfsrevoke man(8) page 2009 中文译本.html", + "https://lishouzhong.com/file_share/translation/FreeBSD 13 NFSv4 nfsuserd man(8) page 2019 中文译本.html", + "https://lishouzhong.com/file_share/translation/FreeBSD 13 rpcbind man(8) page 2017 中文译本.html", + "https://lishouzhong.com/file_share/translation/EasyRSA Intro-To-PKI v3.08 中文译本.html", + "https://lishouzhong.com/file_share/translation/EasyRSA-Advanced v3.08 中文译本.html", + "https://lishouzhong.com/file_share/translation/EasyRSA-Readme v3.08 中文译本.html", + "https://lishouzhong.com/file_share/translation/EasyRSA-Upgrade-Notes v3.08 中文译本.html", + "https://lishouzhong.com/file_share/translation/iperf3 v3.9 man page 中文译本.html", + "https://lishouzhong.com/file_share/translation/PostgreSQL Don't Do This 中文译本.html", + "https://lishouzhong.com/file_share/translation/rsync v3.2.7 man(1) page 中文译本.html", + ], // entryLimit: 10000, - // customPages: [], // filter: (page) => { }, // lastmod: new Date('2022-02-24'), // serialize(item) { diff --git a/script/build_on_linux.sh b/script/build_on_linux.sh index 736c00e..c4846f7 100644 --- a/script/build_on_linux.sh +++ b/script/build_on_linux.sh @@ -8,11 +8,21 @@ script_path="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" original_article_home="/home/ld/Documents/ld_article" original_article_destination="/opt/ld-site/src/content" ld_site_dist_target="/opt/nginx_targets/ld_site_dist" +translation_article_path="/opt/nginx_targets/file_share/translation" rsync -a --delete-after -f"P config.ts" \ "${original_article_home}/" \ "${original_article_destination}/" +cd "${original_article_destination}/translation" +makeinfo --html --no-split --css-include=theme.css ./*.texi +if [ $? -ne 0 ]; then + echo "cannot generate translation article, check 'makeinfo' command output." + exit 1 +fi +rm -rf "${translation_article_path}/*.html" +mv ./*.html "${translation_article_path}/" + cd "${script_path}/../" npm run build @@ -21,6 +31,6 @@ if [ $? -ne 0 ]; then exit 1 fi -mv ${ld_site_dist_target} "${ld_site_dist_target}-old" +mv ${ld_site_dist_target} "${ld_site_dist_target}_old" mv dist ${ld_site_dist_target} -rm -rf "${ld_site_dist_target}-old" +rm -rf "${ld_site_dist_target}_old" diff --git a/src/pages/article/translation/[...translation].astro b/src/pages/article/translation/[...translation].astro deleted file mode 100644 index c3308a5..0000000 --- a/src/pages/article/translation/[...translation].astro +++ /dev/null @@ -1,34 +0,0 @@ ---- -import { getCollection } from "astro:content"; -import type { - CollectionEntry, - CollectionKey, - ContentEntryMap, -} from "astro:content"; -import Footer from "../../../components/Footer.astro"; -import Nav from "../../../components/Nav.astro"; -import ArticleBodyWrapper from "../../../components/article/article_body/ArticleBodyWrapper.astro"; -import DefaultLayout from "../../../layouts/DefaultLayout.astro"; - -export async function getStaticPaths() { - const collectionName: CollectionKey = "translation"; - const blogEntries = await getCollection(collectionName); - return blogEntries.map((entry) => ({ - params: { translation: entry.slug }, - props: { entry }, - })); -} - -interface Props { - entry: CollectionEntry; -} -const { entry } = Astro.props; - -const articlePrettyName: string = entry.id.split("/").pop()!.replace(".md", ""); ---- - - -