@brianlovin/notion-skills
Version:
Sync agent skills from a Notion database to Claude Code, Codex, OpenCode, Cursor, Gemini CLI.
35 lines • 1.36 kB
JavaScript
import { slugify } from "./convert.js";
import { readTitle } from "./notion.js";
/**
* Group active pages by slugified title and return only the groups
* with more than one member. `null`/empty titles are skipped (those
* pages surface as "invalid" elsewhere). Archived / trashed pages
* never participate.
*
* Slugs are the primary identifier on the local machine; two Notion
* pages slugifying to the same string is unambiguously a problem.
* sync skips them with a warning, install refuses them, doctor
* surfaces them so the user can rename one in Notion.
*/
export function detectSlugCollisions(pages) {
const groups = new Map();
for (const page of pages) {
if (page.archived || page.in_trash)
continue;
const title = readTitle(page.properties);
if (!title)
continue;
const slug = slugify(title);
const group = groups.get(slug) ?? { titles: [], pageIds: [] };
group.titles.push(title);
group.pageIds.push(page.id);
groups.set(slug, group);
}
return [...groups.entries()]
.filter(([, g]) => g.pageIds.length > 1)
.map(([slug, g]) => ({ slug, titles: g.titles, pageIds: g.pageIds }));
}
export function collidingSlugSet(collisions) {
return new Set(collisions.map((c) => c.slug));
}
//# sourceMappingURL=slug-collisions.js.map