Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions components/search-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { useMemo, useState } from 'react';
import { useDocsSearch } from 'fumadocs-core/search/client';
import type { SearchLink, SharedProps } from 'fumadocs-ui/contexts/search';
import { useI18n } from 'fumadocs-ui/contexts/i18n';
import {
SearchDialog,
SearchDialogClose,
Expand All @@ -27,12 +26,10 @@ export function CovenSearchDialog({
links = [],
...props
}: SharedProps & { links?: SearchLink[] }) {
const { locale } = useI18n();
const [tag, setTag] = useState<string | undefined>();
const [filterOpen, setFilterOpen] = useState(false);
const { search, setSearch, query } = useDocsSearch({
type: 'fetch',
locale,
tag,
});

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"type": "module",
"scripts": {
"dev": "next dev",
"build": "next build",
"build": "npm run check:english-only && next build",
"check:fumadocs": "node scripts/check-fumadocs-platform.mjs",
"check:english-only": "node scripts/check-english-only.mjs",
"check:links": "node scripts/validate-links.mjs",
"check:mermaid": "node scripts/check-mermaid-transform.mjs && node scripts/check-mermaid-svg-normalize.mjs",
"export:pdf": "node scripts/export-pdf.mjs",
Expand Down
63 changes: 63 additions & 0 deletions scripts/check-english-only.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import fs from 'node:fs';
import path from 'node:path';

const root = process.cwd();
const forbiddenLocaleDirs = new Set([
'ar',
'de',
'es',
'fr',
'it',
'ja',
'ko',
'pt',
'ru',
'zh',
'zh-CN',
'zh-TW',
]);
const ignoredDirs = new Set(['.git', '.next', '.source', 'node_modules']);

function walk(dir) {
const entries = fs.readdirSync(dir, { withFileTypes: true });
const matches = [];

for (const entry of entries) {
if (!entry.isDirectory()) continue;
if (ignoredDirs.has(entry.name)) continue;

const entryPath = path.join(dir, entry.name);
const relative = path.relative(root, entryPath).replace(/\\/g, '/');

if (forbiddenLocaleDirs.has(entry.name)) {
matches.push(relative);
continue;
}

matches.push(...walk(entryPath));
}

return matches;
}

const localeDirectories = walk(root);
Comment on lines +5 to +43
if (localeDirectories.length > 0) {
throw new Error(`Non-English locale directories are not allowed:\n${localeDirectories.join('\n')}`);
}

const searchDialog = fs.readFileSync(path.join(root, 'components/search-dialog.tsx'), 'utf8');
if (searchDialog.includes('useI18n') || searchDialog.includes('locale,')) {
throw new Error('Search must stay English-only and must not depend on Fumadocs locale context.');
}

const rootLayout = fs.readFileSync(path.join(root, 'app/layout.tsx'), 'utf8');
if (!rootLayout.includes('<html lang="en"')) {
throw new Error('Root layout must explicitly declare English as the only document language.');
}

const searchRoute = fs.readFileSync(path.join(root, 'app/api/search/route.ts'), 'utf8');
if (!searchRoute.includes("language: 'english'")) {
throw new Error('Search route must use English stemming.');
}

console.log('Docs site is configured as English-only.');