Skip to content

Commit c191274

Browse files
committed
首页信息:2026-06-18 20:13
1 parent 807804b commit c191274

25 files changed

Lines changed: 313 additions & 111 deletions

‎astro.config.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const viteConfig = {
3636

3737
export default defineConfig({
3838
compressHTML: true,
39-
site: 'https://hjsec.github.io',
39+
site: 'http://125.217.53.158:8060',
4040
integrations: [compress(), icon(), mdx(), sitemap()],
4141
vite: viteConfig,
4242
env: {

‎csv2mdx.mjs‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import { parse } from 'csv-parse/sync';
4+
5+
const csvFile = process.argv[2] || 'members.csv';
6+
const outputDir = 'src/content/projects';
7+
8+
if (!fs.existsSync(csvFile)) {
9+
console.error(`错误:找不到文件 ${csvFile}`);
10+
process.exit(1);
11+
}
12+
13+
const csvData = fs.readFileSync(csvFile, 'utf-8');
14+
const records = parse(csvData, {
15+
columns: true,
16+
skip_empty_lines: true,
17+
trim: true,
18+
});
19+
20+
fs.mkdirSync(outputDir, { recursive: true });
21+
22+
records.forEach((row) => {
23+
const { id, name, image, bio, motto, grade, links } = row;
24+
25+
// 解析 links
26+
const linkList = [];
27+
if (links) {
28+
links.split(',').forEach((item) => {
29+
const [type, url] = item.split(':').map(s => s.trim());
30+
if (type && url) {
31+
linkList.push({ [type]: url });
32+
}
33+
});
34+
}
35+
36+
const yamlLinks = linkList.length
37+
? linkList
38+
.map((l) => {
39+
const [k, v] = Object.entries(l)[0];
40+
return ` - ${k}: "${v}"`;
41+
})
42+
.join('\n')
43+
: ''; // 空数组时,后面会用 links: []
44+
45+
const linksYaml = linkList.length ? `links:\n${yamlLinks}` : 'links: []';
46+
47+
const frontMatter = `---
48+
title: "${name}"
49+
author: "花江安全局"
50+
description: "${bio}"
51+
tags: ["${grade}级"]
52+
image: "/img/${id}.jpeg"
53+
motto: "${motto || ''}"
54+
${linksYaml}
55+
---`;
56+
57+
const body = `这里是 ${name} 的个人介绍页面。`;
58+
59+
const mdxContent = `${frontMatter}\n\n${body}\n`;
60+
const filePath = path.join(outputDir, `${id}.mdx`);
61+
fs.writeFileSync(filePath, mdxContent, 'utf-8');
62+
console.log(`✅ 生成 ${id}.mdx`);
63+
});
64+
65+
console.log('🎉 完成!所有成员文件已生成到 src/content/projects/');

‎members.csv‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
id,name,image,bio,motto,grade,links
2+
id,用户名,id.jpeg,"个人介绍(用英文引号引起来!!!记住是英文)","格言(用英文引号引起来!!!记住是英文)",25,"博客或者github链接,其他公开链接也行"

‎package-lock.json‎

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
"@tailwindcss/vite": "^4.2.4",
5757
"accessible-astro-components": "^5.2.0",
5858
"accessible-astro-launcher": "^2.0.0",
59-
"astro-seo": "^1.1.0"
59+
"astro-seo": "^1.1.0",
60+
"csv-parse": "^7.0.0"
6061
},
6162
"overrides": {
6263
"vite": "^7"

‎public/img/door.jpg‎

74.1 KB
Loading

‎public/img/id.jpeg‎

34.6 KB
Loading

‎public/img/inside.jpg‎

112 KB
Loading

‎public/img/total.jpg‎

121 KB
Loading

‎public/img/xuanchuan.jpg‎

104 KB
Loading

0 commit comments

Comments
 (0)