mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
chore(repo): prune dead code and duplicate abstractions (#3413)
This commit is contained in:
1 parent
c17091768c
commit
c9fdf8fead
2937 files changed
+42233
-176793
No files matched your search
@@ -3,7 +3,7 @@
|
||||
import {readFile} from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {DOCS_ROOT, listDraftMarkdownFiles, listMarkdownFiles, slugifyHeading} from './DocsSource.ts';
|
||||
import {DOCS_ROOT, listDraftMarkdownFiles, listMarkdownFiles, pageSlug, slugifyHeading} from './DocsSource.ts';
|
||||
|
||||
const ASTRO_CONFIG = fileURLToPath(new URL('../astro.config.ts', import.meta.url));
|
||||
|
||||
@@ -11,15 +11,6 @@ const SIDEBAR_START = 'sidebar: [';
|
||||
const QUOTED_ENTRY = /'([^']+)'/gu;
|
||||
const LINK_ENTRY = /link:\s*'([^']+)'/gu;
|
||||
|
||||
function slugOf(file: string): string {
|
||||
const relative = path.relative(DOCS_ROOT, file);
|
||||
const withoutExtension = relative.replace(/\.(mdx|md)$/u, '');
|
||||
if (withoutExtension === 'index') {
|
||||
return '';
|
||||
}
|
||||
return withoutExtension.replace(/\/index$/u, '');
|
||||
}
|
||||
|
||||
function sidebarBlock(source: string): string {
|
||||
const start = source.indexOf(SIDEBAR_START);
|
||||
if (start === -1) {
|
||||
@@ -70,7 +61,7 @@ for (const match of block.matchAll(QUOTED_ENTRY)) {
|
||||
}
|
||||
|
||||
const files = await listMarkdownFiles(DOCS_ROOT);
|
||||
const actual = new Set(files.map(slugOf));
|
||||
const actual = new Set(files.map((file) => pageSlug(path.relative(DOCS_ROOT, file))));
|
||||
|
||||
const missingPages = [...referenced].filter((slug) => !actual.has(slug)).sort();
|
||||
const orphanPages = [...actual].filter((slug) => !referenced.has(slug)).sort();
|
||||
@@ -107,7 +98,7 @@ const anchorable = new Set(actual);
|
||||
const anchorsByPage = new Map<string, Set<string>>();
|
||||
const ambiguousByPage = new Map<string, Set<string>>();
|
||||
for (const file of files) {
|
||||
const slug = slugOf(file);
|
||||
const slug = pageSlug(path.relative(DOCS_ROOT, file));
|
||||
const source = await readFile(file, 'utf8');
|
||||
const anchors = new Set<string>();
|
||||
const counts = new Map<string, number>();
|
||||
@@ -134,7 +125,7 @@ for (const file of files) {
|
||||
|
||||
for (const file of files) {
|
||||
const relative = path.relative(DOCS_ROOT, file);
|
||||
const selfSlug = slugOf(file);
|
||||
const selfSlug = pageSlug(path.relative(DOCS_ROOT, file));
|
||||
const source = await readFile(file, 'utf8');
|
||||
for (const match of source.matchAll(INTERNAL_LINK)) {
|
||||
const target = match[1].replace(/^\//u, '').replace(/\/$/u, '');
|
||||
|
||||
Reference in new issue
Block a user