mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
docs(site): add Slider and Tooltip API reference pages (#862)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
487be3ea96
commit
7a5ce94bca
@@ -82,7 +82,7 @@ function createSections(source, options) {
|
||||
* The shared model is what prevents anchor drift: ids are computed once and
|
||||
* reused verbatim by the renderer and the remark plugin.
|
||||
*/
|
||||
export function createComponentReferenceModel(componentName, apiReference) {
|
||||
export function createComponentReferenceModel(componentName, apiReference, partOrder) {
|
||||
if (!apiReference) {
|
||||
return null;
|
||||
}
|
||||
@@ -90,7 +90,18 @@ export function createComponentReferenceModel(componentName, apiReference) {
|
||||
const hasParts = Boolean(apiReference.parts && Object.keys(apiReference.parts).length > 0);
|
||||
|
||||
if (hasParts) {
|
||||
const parts = Object.entries(apiReference.parts).map(([partId, part]) => ({
|
||||
let partEntries = Object.entries(apiReference.parts);
|
||||
|
||||
if (partOrder) {
|
||||
const orderMap = new Map(partOrder.map((id, i) => [id, i]));
|
||||
partEntries = partEntries.slice().sort((a, b) => {
|
||||
const ai = orderMap.has(a[0]) ? orderMap.get(a[0]) : Number.MAX_SAFE_INTEGER;
|
||||
const bi = orderMap.has(b[0]) ? orderMap.get(b[0]) : Number.MAX_SAFE_INTEGER;
|
||||
return ai - bi;
|
||||
});
|
||||
}
|
||||
|
||||
const parts = partEntries.map(([partId, part]) => ({
|
||||
id: partId,
|
||||
name: part.name,
|
||||
description: part.description,
|
||||
|
||||
@@ -136,7 +136,10 @@ function injectComponentReferenceHeadings(node, headingsWithMetadata, reservedSl
|
||||
const json = readComponentRefJson(componentName);
|
||||
if (!json) return;
|
||||
|
||||
const componentModel = createComponentReferenceModel(componentName, json);
|
||||
const partOrderAttr = node.attributes?.find((a) => a.name === 'partOrder');
|
||||
const partOrder = extractArrayValue(partOrderAttr);
|
||||
|
||||
const componentModel = createComponentReferenceModel(componentName, json, partOrder);
|
||||
const componentHeadings = buildComponentReferenceTocHeadings(componentModel);
|
||||
|
||||
headingsWithMetadata.push(...componentHeadings);
|
||||
|
||||
Reference in New Issue
Block a user