<template>
    <Anchor v-if="nodes !== null" :affix="false">
        <AnchorLink v-for="node in nodes" :key="node.name" :href="'#' + node.name" :title="node.name">
            <AnchorList :nodes="node.nodes"></AnchorList>
        </AnchorLink>
    </Anchor>
</template>

<script setup>
defineProps({
    /**
     * 输出示例：
     * [{
     *     "name": "1",
     *     "nodes": [{
     *         "name": "1.1",
     *         "nodes": []
     *     }]
     * },
     * {
     *     "name": "2",
     *     "nodes": [{
     *         "name": "2.1",
     *         "nodes": []
     *     }]
     * }]
     */
    nodes: {
        type: Array,
        required: false,
        default: () => {
            return null;
        }
    },
});
</script>