tangled
alpha
login
or
join now
stevedylan.dev
/
sequoia
A CLI for publishing standard.site documents to ATProto
sequoia.pub
standard
site
lexicon
cli
publishing
30
fork
atom
overview
issues
5
pulls
1
pipelines
chore: adapted inject.ts pattern
stevedylan.dev
1 week ago
c02891dd
16e25f5f
+29
-2
1 changed file
expand all
collapse all
unified
split
packages
cli
src
commands
inject.ts
+29
-2
packages/cli/src/commands/inject.ts
···
43
43
// Load state to get atUri mappings
44
44
const state = await loadState(configDir);
45
45
46
46
+
// Generic filenames where the slug is the parent directory, not the filename
47
47
+
// Covers: SvelteKit (+page), Astro/Hugo (index), Next.js (page), etc.
48
48
+
const genericFilenames = new Set([
49
49
+
"+page",
50
50
+
"index",
51
51
+
"_index",
52
52
+
"page",
53
53
+
"readme",
54
54
+
]);
55
55
+
46
56
// Build a map of slug/path to atUri from state
47
57
const pathToAtUri = new Map<string, string>();
48
58
for (const [filePath, postState] of Object.entries(state.posts)) {
49
59
if (postState.atUri) {
50
60
// Extract slug from file path (e.g., ./content/blog/my-post.md -> my-post)
51
51
-
const basename = path.basename(filePath, path.extname(filePath));
61
61
+
let basename = path.basename(filePath, path.extname(filePath));
62
62
+
63
63
+
// If the filename is a generic convention name, use the parent directory as slug
64
64
+
if (genericFilenames.has(basename.toLowerCase())) {
65
65
+
// Split path and filter out route groups like (blog-article)
66
66
+
const pathParts = filePath
67
67
+
.split(/[/\\]/)
68
68
+
.filter((p) => p && !(p.startsWith("(") && p.endsWith(")")));
69
69
+
// The slug should be the second-to-last part (last is the filename)
70
70
+
if (pathParts.length >= 2) {
71
71
+
const slug = pathParts[pathParts.length - 2];
72
72
+
if (slug && slug !== "." && slug !== "content" && slug !== "routes" && slug !== "src") {
73
73
+
basename = slug;
74
74
+
}
75
75
+
}
76
76
+
}
77
77
+
52
78
pathToAtUri.set(basename, postState.atUri);
53
79
54
80
// Also add variations that might match HTML file paths
55
81
// e.g., /blog/my-post, /posts/my-post, my-post/index
56
82
const dirName = path.basename(path.dirname(filePath));
57
57
-
if (dirName !== "." && dirName !== "content") {
83
83
+
// Skip route groups and common directory names
84
84
+
if (dirName !== "." && dirName !== "content" && !(dirName.startsWith("(") && dirName.endsWith(")"))) {
58
85
pathToAtUri.set(`${dirName}/${basename}`, postState.atUri);
59
86
}
60
87
}