mirror of
https://github.com/prompt-security/clawsec.git
synced 2026-06-13 13:38:03 +03:00
fefecaa60a
* feat(wiki): add full in-app wiki browser and llms index * feat(wiki): auto-generate per-page llms exports * vuln package * fix(wiki): guard malformed route decoding * fix(wiki): preserve markdown anchor fragments across page links * refactor(markdown): share default render components * fix(wiki): block unsafe markdown link schemes * fix(wiki): block unsafe markdown image schemes * docs(wiki): migrate root docs into wiki pages * chore(wiki): de-track generated llms exports * chore(wiki): ignore generated public wiki artifacts * fix(wiki): align llms urls with per-page endpoint pattern * fix(wiki): derive llms index from wiki index page * refactor(markdown): share frontmatter and title helpers * refactor(wiki): share route and llms path mapping * ci(pages): add pr verify workflow and tighten deploy triggers
39 lines
1022 B
JavaScript
39 lines
1022 B
JavaScript
/**
|
|
* Normalize a wiki slug for route/path construction.
|
|
* @param {string} slug
|
|
* @returns {string}
|
|
*/
|
|
const normalizeWikiSlug = (slug) =>
|
|
String(slug ?? '')
|
|
.replace(/\\/g, '/')
|
|
.replace(/^\/+|\/+$/g, '');
|
|
|
|
/**
|
|
* Return whether a slug represents the wiki index page.
|
|
* @param {string} slug
|
|
* @returns {boolean}
|
|
*/
|
|
export const isWikiIndexSlug = (slug) => normalizeWikiSlug(slug).toLowerCase() === 'index';
|
|
|
|
/**
|
|
* Convert a wiki slug to app route path.
|
|
* @param {string} slug
|
|
* @returns {string}
|
|
*/
|
|
export const toWikiRoute = (slug) => {
|
|
const normalized = normalizeWikiSlug(slug);
|
|
if (!normalized || isWikiIndexSlug(normalized)) return '/wiki';
|
|
return `/wiki/${normalized}`;
|
|
};
|
|
|
|
/**
|
|
* Convert a wiki slug to its llms.txt endpoint path.
|
|
* @param {string} slug
|
|
* @returns {string}
|
|
*/
|
|
export const toWikiLlmsPath = (slug) => {
|
|
const normalized = normalizeWikiSlug(slug);
|
|
if (!normalized || isWikiIndexSlug(normalized)) return '/wiki/llms.txt';
|
|
return `/wiki/${normalized}/llms.txt`;
|
|
};
|