From 09f493ddbc909993849813e30dcf0fc8deca6243 Mon Sep 17 00:00:00 2001 From: Zuoling Rong Date: Fri, 31 Jan 2025 21:51:24 +0800 Subject: [PATCH] 1.0 --- .github/workflows/deploy.yml | 35 + config.yml | 220 ++ generator.js | 179 + index.html | 52 +- node_modules/.bin/js-yaml | 16 + node_modules/.bin/js-yaml.cmd | 17 + node_modules/.bin/js-yaml.ps1 | 28 + node_modules/.package-lock.json | 26 + node_modules/argparse/CHANGELOG.md | 216 ++ node_modules/argparse/LICENSE | 254 ++ node_modules/argparse/README.md | 84 + node_modules/argparse/argparse.js | 3707 ++++++++++++++++++ node_modules/argparse/lib/sub.js | 67 + node_modules/argparse/lib/textwrap.js | 440 +++ node_modules/argparse/package.json | 31 + node_modules/js-yaml/CHANGELOG.md | 616 +++ node_modules/js-yaml/LICENSE | 21 + node_modules/js-yaml/README.md | 246 ++ node_modules/js-yaml/bin/js-yaml.js | 126 + node_modules/js-yaml/dist/js-yaml.js | 3874 +++++++++++++++++++ node_modules/js-yaml/dist/js-yaml.min.js | 2 + node_modules/js-yaml/dist/js-yaml.mjs | 3851 ++++++++++++++++++ node_modules/js-yaml/index.js | 47 + node_modules/js-yaml/lib/common.js | 59 + node_modules/js-yaml/lib/dumper.js | 965 +++++ node_modules/js-yaml/lib/exception.js | 55 + node_modules/js-yaml/lib/loader.js | 1727 +++++++++ node_modules/js-yaml/lib/schema.js | 121 + node_modules/js-yaml/lib/schema/core.js | 11 + node_modules/js-yaml/lib/schema/default.js | 22 + node_modules/js-yaml/lib/schema/failsafe.js | 17 + node_modules/js-yaml/lib/schema/json.js | 19 + node_modules/js-yaml/lib/snippet.js | 101 + node_modules/js-yaml/lib/type.js | 66 + node_modules/js-yaml/lib/type/binary.js | 125 + node_modules/js-yaml/lib/type/bool.js | 35 + node_modules/js-yaml/lib/type/float.js | 97 + node_modules/js-yaml/lib/type/int.js | 156 + node_modules/js-yaml/lib/type/map.js | 8 + node_modules/js-yaml/lib/type/merge.js | 12 + node_modules/js-yaml/lib/type/null.js | 35 + node_modules/js-yaml/lib/type/omap.js | 44 + node_modules/js-yaml/lib/type/pairs.js | 53 + node_modules/js-yaml/lib/type/seq.js | 8 + node_modules/js-yaml/lib/type/set.js | 29 + node_modules/js-yaml/lib/type/str.js | 8 + node_modules/js-yaml/lib/type/timestamp.js | 88 + node_modules/js-yaml/package.json | 66 + package-lock.json | 34 + package.json | 19 + 50 files changed, 18130 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/deploy.yml create mode 100644 config.yml create mode 100644 generator.js create mode 100644 node_modules/.bin/js-yaml create mode 100644 node_modules/.bin/js-yaml.cmd create mode 100644 node_modules/.bin/js-yaml.ps1 create mode 100644 node_modules/.package-lock.json create mode 100644 node_modules/argparse/CHANGELOG.md create mode 100644 node_modules/argparse/LICENSE create mode 100644 node_modules/argparse/README.md create mode 100644 node_modules/argparse/argparse.js create mode 100644 node_modules/argparse/lib/sub.js create mode 100644 node_modules/argparse/lib/textwrap.js create mode 100644 node_modules/argparse/package.json create mode 100644 node_modules/js-yaml/CHANGELOG.md create mode 100644 node_modules/js-yaml/LICENSE create mode 100644 node_modules/js-yaml/README.md create mode 100644 node_modules/js-yaml/bin/js-yaml.js create mode 100644 node_modules/js-yaml/dist/js-yaml.js create mode 100644 node_modules/js-yaml/dist/js-yaml.min.js create mode 100644 node_modules/js-yaml/dist/js-yaml.mjs create mode 100644 node_modules/js-yaml/index.js create mode 100644 node_modules/js-yaml/lib/common.js create mode 100644 node_modules/js-yaml/lib/dumper.js create mode 100644 node_modules/js-yaml/lib/exception.js create mode 100644 node_modules/js-yaml/lib/loader.js create mode 100644 node_modules/js-yaml/lib/schema.js create mode 100644 node_modules/js-yaml/lib/schema/core.js create mode 100644 node_modules/js-yaml/lib/schema/default.js create mode 100644 node_modules/js-yaml/lib/schema/failsafe.js create mode 100644 node_modules/js-yaml/lib/schema/json.js create mode 100644 node_modules/js-yaml/lib/snippet.js create mode 100644 node_modules/js-yaml/lib/type.js create mode 100644 node_modules/js-yaml/lib/type/binary.js create mode 100644 node_modules/js-yaml/lib/type/bool.js create mode 100644 node_modules/js-yaml/lib/type/float.js create mode 100644 node_modules/js-yaml/lib/type/int.js create mode 100644 node_modules/js-yaml/lib/type/map.js create mode 100644 node_modules/js-yaml/lib/type/merge.js create mode 100644 node_modules/js-yaml/lib/type/null.js create mode 100644 node_modules/js-yaml/lib/type/omap.js create mode 100644 node_modules/js-yaml/lib/type/pairs.js create mode 100644 node_modules/js-yaml/lib/type/seq.js create mode 100644 node_modules/js-yaml/lib/type/set.js create mode 100644 node_modules/js-yaml/lib/type/str.js create mode 100644 node_modules/js-yaml/lib/type/timestamp.js create mode 100644 node_modules/js-yaml/package.json create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..d55080e --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,35 @@ +name: Deploy Navigation Site + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '16' + + - name: Install dependencies + run: | + npm init -y + npm install js-yaml + + - name: Generate site + run: node generator.js + + - name: Deploy to GitHub Pages + uses: JamesIves/github-pages-deploy-action@4.1.4 + with: + branch: gh-pages + folder: . + clean: true \ No newline at end of file diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..870c646 --- /dev/null +++ b/config.yml @@ -0,0 +1,220 @@ +# 网站基本信息 +site: + title: 我的导航 + description: 个人网络导航站 + author: Your Name + +# 个人信息 +profile: + title: Hello, + subtitle: Welcome to My Navigation + description: Front-end Developer / Open Source Enthusiast / Blogger + +# 导航菜单 +navigation: + - name: 首页 + icon: fas fa-home + id: home + active: true + - name: 项目 + icon: fas fa-project-diagram + id: projects + - name: 文章 + icon: fas fa-book + id: articles + - name: 朋友 + icon: fas fa-users + id: friends + +# 社交账号 +social: + - name: GitHub + url: https://github.com + icon: fab fa-github + - name: Telegram + url: https://t.me + icon: fab fa-telegram + - name: Twitter + url: https://twitter.com + icon: fab fa-twitter + - name: Steam + url: https://steam.com + icon: fab fa-steam + +# 首页分类 +categories: + - name: 常用网站 + icon: fas fa-star + sites: + - name: Google + url: https://www.google.com + icon: fab fa-google + description: 全球最大的搜索引擎 + - name: GitHub + url: https://www.github.com + icon: fab fa-github + description: 代码托管平台 + + - name: 学习资源 + icon: fas fa-graduation-cap + sites: + - name: 哔哩哔哩 + url: https://www.bilibili.com + icon: fas fa-play-circle + description: 视频学习平台 + - name: 知乎 + url: https://www.zhihu.com + icon: fas fa-question-circle + description: 问答社区 + +# 项目页面 +projects: + title: 我的项目 + subtitle: 这里展示了我的一些个人项目和开源贡献 + categories: + - name: 个人项目 + icon: fas fa-code + sites: + - name: 个人导航站 + icon: fas fa-compass + description: 一个简洁美观的个人导航页面 + url: "#" + - name: Todo List + icon: fas fa-tasks + description: 基于Vue3的待办事项管理器 + url: "#" + - name: 个人博客 + icon: fas fa-blog + description: 使用Hexo搭建的技术博客 + url: "#" + - name: 开源贡献 + icon: fas fa-code-branch + sites: + - name: Project A + icon: fab fa-github + description: 开源项目贡献 + url: "#" + - name: Project B + icon: fab fa-github + description: 开源项目贡献 + url: "#" + +# 文章页面 +articles: + title: 技术文章 + subtitle: 分享我的技术文章和学习笔记 + categories: + - name: 最新文章 + icon: fas fa-pen + sites: + - name: Vue3最佳实践 + icon: fab fa-vuejs + description: Vue3组合式API的使用技巧 + url: "#" + - name: JavaScript进阶 + icon: fab fa-js + description: JavaScript高级特性解析 + url: "#" + - name: Git使用技巧 + icon: fab fa-git-alt + description: Git常用命令和工作流 + url: "#" + - name: Docker入门 + icon: fab fa-docker + description: Docker基础知识和实践 + url: "#" + - name: 学习笔记 + icon: fas fa-book + sites: + - name: React Hooks + icon: fab fa-react + description: React Hooks最佳实践 + url: "#" + - name: Node.js实战 + icon: fab fa-node-js + description: Node.js服务端开发笔记 + url: "#" + - name: CSS技巧 + icon: fab fa-css3 + description: CSS常用技巧总结 + url: "#" + - name: 数据库设计 + icon: fas fa-database + description: 数据库架构和优化笔记 + url: "#" + - name: 源码解析 + icon: fas fa-code + sites: + - name: Vue源码解析 + icon: fab fa-vuejs + description: Vue.js核心原理解析 + url: "#" + - name: React原理 + icon: fab fa-react + description: React核心机制解析 + url: "#" + +# 朋友页面 +friends: + title: 友情链接 + subtitle: 优秀的博主和朋友们 + categories: + - name: 技术博主 + icon: fas fa-user-friends + sites: + - name: 小明的博客 + icon: fas fa-code + description: 全栈开发工程师,分享技术心得 + url: "#" + - name: 小红的前端 + icon: fas fa-paint-brush + description: 专注前端开发与设计 + url: "#" + - name: 小张的后端 + icon: fas fa-server + description: 分享后端开发经验 + url: "#" + - name: 小李的移动端 + icon: fas fa-mobile-alt + description: 移动应用开发专家 + url: "#" + + - name: 技术社区 + icon: fas fa-laptop-code + sites: + - name: GitHub + icon: fab fa-github + description: 开源代码托管平台 + url: https://github.com + - name: Stack Overflow + icon: fab fa-stack-overflow + description: 程序员问答社区 + url: https://stackoverflow.com + - name: 掘金 + icon: fas fa-book + description: 高质量技术社区 + url: https://juejin.cn + - name: V2EX + icon: fas fa-comments + description: 创意工作者社区 + url: https://v2ex.com + + - name: 休闲娱乐 + icon: fas fa-coffee + sites: + - name: 哔哩哔哩 + icon: fas fa-play-circle + description: 视频弹幕网站 + url: https://www.bilibili.com + - name: 知乎 + icon: fas fa-question-circle + description: 问答社区 + url: https://www.zhihu.com + - name: 豆瓣 + icon: fas fa-film + description: 文艺生活社区 + url: https://www.douban.com + - name: 网易云音乐 + icon: fas fa-music + description: 音乐平台 + url: https://music.163.com \ No newline at end of file diff --git a/generator.js b/generator.js new file mode 100644 index 0000000..f13b285 --- /dev/null +++ b/generator.js @@ -0,0 +1,179 @@ +const fs = require('fs'); +const yaml = require('js-yaml'); +const path = require('path'); + +// 读取配置文件 +function loadConfig() { + try { + const configFile = fs.readFileSync('config.yml', 'utf8'); + return yaml.load(configFile); + } catch (e) { + console.error('Error loading config file:', e); + process.exit(1); + } +} + +// 生成导航菜单 +function generateNavigation(navigation) { + return navigation.map(nav => ` + + + ${nav.name} + `).join('\n'); +} + +// 生成网站卡片HTML +function generateSiteCards(sites) { + return sites.map(site => ` + + +

${site.name}

+

${site.description}

+
`).join('\n'); +} + +// 生成分类HTML +function generateCategories(categories) { + return categories.map(category => ` +
+

${category.name}

+
+ ${generateSiteCards(category.sites)} +
+
`).join('\n'); +} + +// 生成社交链接HTML +function generateSocialLinks(social) { + return social.map(link => ` + + + ${link.name} + `).join('\n'); +} + +// 生成页面内容 +function generatePageContent(pageId, data) { + return ` +
+

${data.title}

+

${data.subtitle}

+
+ ${generateCategories(data.categories)}`; +} + +// 生成搜索结果页面 +function generateSearchResultsPage() { + return ` + +
+
+

搜索结果

+

在所有页面中找到的匹配项

+
+ + + + + + + + +
`; +} + +// 生成完整的HTML +function generateHTML(config) { + return ` + + + + + ${config.site.title} + + + + +
+ + + + +
+ + + +
+
+

${config.profile.title}

+

${config.profile.subtitle}

+

${config.profile.description}

+
+${generateCategories(config.categories)} +
+ + +
+${generatePageContent('projects', config.projects)} +
+ + +
+${generatePageContent('articles', config.articles)} +
+ + +
+${generatePageContent('friends', config.friends)} +
+${generateSearchResultsPage()} +
+
+ + +`; +} + +// 主函数 +function main() { + const config = loadConfig(); + const html = generateHTML(config); + + try { + fs.writeFileSync('index.html', html); + console.log('Successfully generated index.html'); + } catch (e) { + console.error('Error writing index.html:', e); + process.exit(1); + } +} + +main(); \ No newline at end of file diff --git a/index.html b/index.html index efb1467..d5af135 100644 --- a/index.html +++ b/index.html @@ -16,18 +16,22 @@