diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..d38aa906 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,21 @@ +.git +.github +.husky +.vscode +.idea + +node_modules +dist +dev +coverage +.nyc_output + +docs +*.log +npm-debug.log* + +.specstory +.spec-workflow +.serena +.claude + diff --git a/.gitattributes b/.gitattributes index f4232526..4e7d7c57 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,6 +7,10 @@ *.yaml text eol=lf *.css text eol=lf *.html text eol=lf +*.sh text eol=lf + +# Husky hooks 必须使用 LF +.husky/* text eol=lf *.png binary *.jpg binary diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..2d8c6473 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,62 @@ +version: 2 + +updates: + - package-ecosystem: npm + directory: / + target-branch: main + schedule: + interval: weekly + day: monday + time: '09:00' + timezone: Asia/Shanghai + open-pull-requests-limit: 10 + labels: + - dependencies + - npm + commit-message: + prefix: chore + include: scope + groups: + security-updates: + applies-to: security-updates + patterns: + - '*' + npm-minor-patch: + applies-to: version-updates + patterns: + - '*' + update-types: + - minor + - patch + + - package-ecosystem: github-actions + directory: / + target-branch: main + schedule: + interval: weekly + day: monday + time: '09:15' + timezone: Asia/Shanghai + open-pull-requests-limit: 10 + labels: + - dependencies + - github-actions + commit-message: + prefix: ci + include: scope + ignore: + - dependency-name: '*' + update-types: + - version-update:semver-major + groups: + security-updates: + applies-to: security-updates + patterns: + - '*' + github-actions-minor-patch: + applies-to: version-updates + patterns: + - '*' + update-types: + - minor + - patch diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b3a4b24..0bed14f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,15 +17,12 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '18' + node-version: '22.12' cache: 'npm' - name: Install dependencies run: npm ci - - name: Format check (changed files) - run: npm run format:check:changed - - name: Lint run: npm run lint diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 00000000..80ccd004 --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,40 @@ +name: Dependabot Auto Merge + +on: + pull_request: + types: + - opened + - synchronize + - reopened + +permissions: + contents: write + pull-requests: write + +concurrency: + group: dependabot-auto-merge-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + auto_merge: + if: github.event.pull_request.user.login == 'dependabot[bot]' + runs-on: ubuntu-latest + steps: + - name: Fetch Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Enable auto-merge for patch and minor updates + if: | + steps.metadata.outputs.update-type == 'version-update:semver-patch' || + steps.metadata.outputs.update-type == 'version-update:semver-minor' + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Keep major updates for manual review + if: steps.metadata.outputs.update-type == 'version-update:semver-major' + run: echo "Major version update detected. Auto-merge is intentionally disabled." diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 66fccfa2..029c21b3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -39,7 +39,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '18' + node-version: '22.12' cache: 'npm' - name: Install dependencies @@ -106,7 +106,6 @@ jobs: git commit -m "chore(bookmarks): 导入书签并写回用户配置" git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" HEAD:${{ github.ref_name }} # --- 书签处理步骤结束 --- - # --- 网站构建和部署步骤 --- # 同步时效性数据(best-effort):projects 仓库信息、articles RSS 聚合 # 说明: @@ -129,17 +128,25 @@ jobs: else echo "Warning: favicon.ico not found in dist directory" # 暂时改为警告,避免因为图标问题阻止部署 - # exit 1 + # exit 1 fi + # GitHub Pages 部署步骤(仅在启用时执行) + # 说明: + # - 如果你使用 Vercel/Cloudflare Pages 等第三方平台部署,可以跳过这些步骤 + # - 设置 repository variable ENABLE_GITHUB_PAGES=false 来禁用 GitHub Pages 部署 + # - 默认启用 GitHub Pages 部署以保持向后兼容 - name: Setup Pages + if: ${{ vars.ENABLE_GITHUB_PAGES != 'false' }} uses: actions/configure-pages@v4 - name: Upload artifact + if: ${{ vars.ENABLE_GITHUB_PAGES != 'false' }} uses: actions/upload-pages-artifact@v3 with: path: 'dist' - name: Deploy to GitHub Pages + if: ${{ vars.ENABLE_GITHUB_PAGES != 'false' }} id: deployment uses: actions/deploy-pages@v4 diff --git a/.github/workflows/docker-ghcr.yml b/.github/workflows/docker-ghcr.yml new file mode 100644 index 00000000..f2719cb4 --- /dev/null +++ b/.github/workflows/docker-ghcr.yml @@ -0,0 +1,57 @@ +name: Docker Publish (GHCR) + +on: + push: + branches: [main] + tags: + - 'v*' + workflow_dispatch: + +permissions: + contents: read + packages: write + +concurrency: + group: docker-ghcr-${{ github.ref }} + cancel-in-progress: true + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=ref,event=tag + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + platforms: linux/amd64,linux/arm64 + labels: ${{ steps.meta.outputs.labels }} + tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.gitignore b/.gitignore index 3c1252d4..2dcba444 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,13 @@ npm-debug.log* # 构建输出 dist/ +.astro/ +public/assets/ +public/pinyin-match.js +public/script.js +public/menav-config.json +public/menav.svg +public/favicon.ico # IDE/编辑器配置 .vscode/ @@ -40,3 +47,4 @@ tests/fixtures/ .specstory/.what-is-this.md AGENTS.md /.claude +/discord-style-navstation diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 00000000..3d9b7581 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +# 进入仓库根目录,避免在子目录执行 git commit 时找不到脚本/依赖 +cd "$(dirname "$0")/.." || exit 1 + +# Windows Git Bash 下如果需要中文输出不乱码,可在个人环境中设置终端编码/locale +# 这里不强制设置 LANG/LC_ALL,避免在 Linux/macOS 上因 locale 不存在而产生警告 + +# 优先使用项目内的 lint-staged,避免依赖全局 PATH +./node_modules/.bin/lint-staged diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..2bd5a0a9 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +22 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..851a24fc --- /dev/null +++ b/.prettierignore @@ -0,0 +1,29 @@ +# 依赖和构建产物 +node_modules/ +dist/ +dev/ + +# npm lockfile(避免提交时产生大面积格式化 diff) +package-lock.json + +# Git 配置文件 +.gitattributes +.gitignore + +# Husky hooks(shell 脚本,不需要 Prettier 格式化) +.husky/ + +# 缓存文件 +*.cache +.cache/ + +# 日志文件 +*.log + +# 临时文件 +*.tmp +*.temp + +# 文档文件(保留排版灵活性,避免代码示例被格式化) +**/README.md +src/**/*.md diff --git a/.prettierrc.json b/.prettierrc.json index 132f5de6..a94365a5 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -3,5 +3,6 @@ "singleQuote": true, "trailingComma": "es5", "tabWidth": 2, - "useTabs": false + "useTabs": false, + "plugins": ["prettier-plugin-astro"] } diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..19eaf541 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,252 @@ +# 更新记录 + +> 本文件维护 MeNav 历史更新记录。README 不再维护"更新记录"章节。 + +### 2026/01/04 + +**1. 首屏性能优化** + +- 移除首页副标题固定 Quicksand 外链字体,改为跟随全站字体 +- 字体外链 CSS 支持 `fonts.preload: true`(`preload + onload` 非阻塞加载,含 `