fix: exclude repository README from docs sitemap (#102)

Co-authored-by: dadachann <[email protected]>
This commit is contained in:
Hyu
2026-07-20 14:25:13 +08:00
committed by GitHub
co-authored by dadachann
parent d92af4ac35
commit 38a21145d9
4 changed files with 57 additions and 1 deletions
+21
View File
@@ -0,0 +1,21 @@
name: Tests
on:
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
seo:
name: SEO publishing contract
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
- name: Run SEO contract tests
run: npm test
+2
View File
@@ -0,0 +1,2 @@
# Repository documentation; not part of the published Mintlify site.
README_EN.md
+2 -1
View File
@@ -1,6 +1,7 @@
{
"scripts": {
"dev": "npx mintlify dev"
"dev": "npx mintlify dev",
"test": "node --test tests/*.test.mjs"
},
"dependencies": {
"mintlify": "^4.2.375"
+32
View File
@@ -0,0 +1,32 @@
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import test from "node:test";
const repoRoot = new URL("../", import.meta.url);
test("repository-only English README is excluded from Mintlify publishing", async () => {
const mintignore = await readFile(new URL(".mintignore", repoRoot), "utf8");
const patterns = mintignore
.split(/\r?\n/)
.map((line) => line.trim())
.filter((line) => line && !line.startsWith("#"));
let ignored = false;
for (const pattern of patterns) {
if (pattern === "README_EN.md") ignored = true;
if (pattern === "!README_EN.md") ignored = false;
}
assert.equal(ignored, true);
});
test("the historical README_EN URL keeps its permanent canonical redirect", async () => {
const docs = JSON.parse(await readFile(new URL("docs.json", repoRoot), "utf8"));
const redirects = docs.redirects.filter(
(item) => item.source === "/README_EN",
);
assert.equal(redirects.length, 1);
assert.equal(redirects[0].destination, "/en/insight/guide");
assert.notEqual(redirects[0].permanent, false);
});