mirror of
https://github.com/prompt-security/clawsec.git
synced 2026-06-22 09:51:21 +03:00
feat(wiki): add full in-app wiki browser and llms index (#80)
* 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
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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`;
|
||||
};
|
||||
Reference in New Issue
Block a user