mirror of
https://github.com/zoriya/v10.git
synced 2026-08-15 02:14:06 +00:00
feat(site): feature and preset reference UI + docs integration (#1258)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
5301202a18
commit
d4b805ea69
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Centralized feature API reference subsection definitions.
|
||||
*
|
||||
* Mirrors componentReferenceModel.js for feature APIs. Produces heading/id data
|
||||
* consumed by both FeatureReference.astro and remarkConditionalHeadings.
|
||||
*
|
||||
* Structure:
|
||||
* ## API Reference (H2)
|
||||
* ### State (H3) — if feature has state properties
|
||||
* ### Actions (H3) — if feature has action methods
|
||||
*/
|
||||
|
||||
function hasEntries(value) {
|
||||
return Object.keys(value ?? {}).length > 0;
|
||||
}
|
||||
|
||||
export function createFeatureReferenceModel(name, ref) {
|
||||
if (!ref) return null;
|
||||
|
||||
const sections = [];
|
||||
|
||||
if (hasEntries(ref.state)) {
|
||||
sections.push({ key: 'state', title: 'State', id: 'state', depth: 3 });
|
||||
}
|
||||
|
||||
if (hasEntries(ref.actions)) {
|
||||
sections.push({ key: 'actions', title: 'Actions', id: 'actions', depth: 3 });
|
||||
}
|
||||
|
||||
return {
|
||||
name,
|
||||
description: ref.description,
|
||||
heading: { id: 'api-reference', depth: 2, text: 'API Reference' },
|
||||
sections,
|
||||
data: ref,
|
||||
};
|
||||
}
|
||||
|
||||
export function buildFeatureReferenceTocHeadings(model) {
|
||||
if (!model) return [];
|
||||
|
||||
const headings = [
|
||||
{
|
||||
depth: model.heading.depth,
|
||||
text: model.heading.text,
|
||||
slug: model.heading.id,
|
||||
},
|
||||
];
|
||||
|
||||
for (const section of model.sections) {
|
||||
headings.push({
|
||||
depth: section.depth,
|
||||
text: section.title,
|
||||
slug: section.id,
|
||||
});
|
||||
}
|
||||
|
||||
return headings;
|
||||
}
|
||||
Reference in New Issue
Block a user