Migrate translation article source code format to texinfo.

This commit is contained in:
liding 2024-10-13 15:45:34 +08:00
parent 9cf9745d49
commit 8b07e121a5
7 changed files with 189 additions and 83 deletions

4
.gitignore vendored
View File

@ -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

View File

@ -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 中,从而可以被搜索引擎收录。

View File

@ -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) {

View File

@ -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"

View File

@ -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<keyof ContentEntryMap>;
}
const { entry } = Astro.props;
const articlePrettyName: string = entry.id.split("/").pop()!.replace(".md", "");
---
<DefaultLayout title=`${articlePrettyName} - 李守中`>
<Nav />
<ArticleBodyWrapper collectionName="translation" articleSlug={entry.slug} />
<Footer />
</DefaultLayout>

View File

@ -1,21 +1,141 @@
---
import Footer from "../../../components/Footer.astro";
import Nav from "../../../components/Nav.astro";
import CollectionSummary from "../../../components/article/CollectionSummary.astro";
import DefaultLayout from "../../../layouts/DefaultLayout.astro";
---
<DefaultLayout title="翻译 - 李守中">
<Nav />
<div class="options">
<span>当前: [按名字排序]</span>
<a href="/article/translation/sort_by_timeline">按日期降序</a>
<div class="collection-desc">
<div class="collection-desc-item">
<h1>freebsd</h1>
<ul>
<li>
<a
href="/file_share/translation/FreeBSD 13 NFS exports man(5) page 2021 中文译本.html"
target="_blank"
>
FreeBSD 13 NFS exports man(5) 2021 中文译本
</a>
</li><li>
<a
href="/file_share/translation/FreeBSD 13 NFS mountd man(8) page 2020 中文译本.html"
target="_blank"
>
FreeBSD 13 NFS mountd man(8) 2020 中文译本
</a>
</li><li>
<a
href="/file_share/translation/FreeBSD 13 NFS nfsd man(8) page 2019 中文译本.html"
target="_blank"
>
FreeBSD 13 NFS nfsd man(8) 2019 中文译本
</a>
</li><li>
<a
href="/file_share/translation/FreeBSD 13 NFS showmount man(8) page 2016 中文译本.html"
target="_blank"
>
FreeBSD 13 NFS showmount man(8) 2016 中文译本
</a>
</li><li>
<a
href="/file_share/translation/FreeBSD 13 NFSv4 man(4) page 2019 中文译本.html"
target="_blank"
>
FreeBSD 13 NFSv4 man(4) 2019 中文译本
</a>
</li><li>
<a
href="/file_share/translation/FreeBSD 13 NFSv4 nfscbd man(8) page 2009 中文译本.html"
target="_blank"
>
FreeBSD 13 NFSv4 nfscbd man(8) 2009 中文译本
</a>
</li><li>
<a
href="/file_share/translation/FreeBSD 13 NFSv4 nfsrevoke man(8) page 2009 中文译本.html"
target="_blank"
>
FreeBSD 13 NFSv4 nfsrevoke man(8) 2020 中文译本
</a>
</li><li>
<a
href="/file_share/translation/FreeBSD 13 NFSv4 nfsuserd man(8) page 2019 中文译本.html"
target="_blank"
>
FreeBSD 13 NFSv4 nfsuserd man(8) 2019 中文译本
</a>
</li><li>
<a
href="/file_share/translation/FreeBSD 13 rpcbind man(8) page 2017 中文译本.html"
target="_blank"
>
FreeBSD 13 rpcbind man(8) 2017 中文译本
</a>
</li>
</ul>
</div><div class="collection-desc-item">
<h1>easyrsa</h1>
<ul>
<li>
<a
href="/file_share/translation/EasyRSA Intro-To-PKI v3.08 中文译本.html"
target="_blank"
>
EasyRSA Intro-To-PKI v3.08 中文译本
</a>
</li><li>
<a
href="/file_share/translation/EasyRSA-Advanced v3.08 中文译本.html"
target="_blank"
>
EasyRSA-Advanced v3.08 中文译本
</a>
</li><li>
<a
href="/file_share/translation/EasyRSA-Readme v3.08 中文译本.html"
target="_blank"
>
EasyRSA-Readme v3.08 中文译本
</a>
</li><li>
<a
href="/file_share/translation/EasyRSA-Upgrade-Notes v3.08 中文译本.html"
target="_blank"
>
EasyRSA-Upgrade-Notes v3.08 中文译本
</a>
</li>
</ul>
</div><div class="collection-desc-item">
<h1>uncategorized</h1>
<ul>
<li>
<a
href="/file_share/translation/iperf3 v3.9 man page 中文译本.html"
target="_blank"
>
iperf3 v3.9 man(1) 中文译本
</a>
</li><li>
<a
href="/file_share/translation/PostgreSQL Don't Do This 中文译本.html"
target="_blank"
>
PostgreSQL Don't Do This 中文译本
</a>
</li><li>
<a
href="/file_share/translation/rsync v3.2.7 man(1) page 中文译本.html"
target="_blank"
>
rsync v3.2.7 man(1) 中文译本
</a>
</li>
</ul>
</div>
</div>
<CollectionSummary
collectionName="translation"
sortByTimeline={false}
sortByArticleTitle={true}
/>
<Footer />
</DefaultLayout>
@ -34,4 +154,19 @@ import DefaultLayout from "../../../layouts/DefaultLayout.astro";
.options {
margin: 0.5em 0 0 0;
}
.collection-desc::after {
display: block;
content: "";
clear: both;
}
ul {
padding: 0;
list-style-type: none;
}
h1 {
margin: 0.5em 0 0 0;
}
</style>

View File

@ -1,37 +0,0 @@
---
import Footer from "../../../components/Footer.astro";
import Nav from "../../../components/Nav.astro";
import CollectionSummary from "../../../components/article/CollectionSummary.astro";
import DefaultLayout from "../../../layouts/DefaultLayout.astro";
---
<DefaultLayout title="翻译 - 李守中">
<Nav />
<div class="options">
<span>当前: [按日期降序]</span>
<a href="/article/translation/">按名字排序</a>
</div>
<CollectionSummary
collectionName="translation"
sortByTimeline={true}
sortByArticleTitle={false}
/>
<Footer />
</DefaultLayout>
<style>
:global(@media screen and (max-width: 1024px)) {
.collection-desc-item {
width: 100%;
}
}
:global(@media screen and (min-width: 1024px)) {
.collection-desc-item {
width: 50%;
float: left;
}
}
.options {
margin: 0.5em 0 0 0;
}
</style>