@wordpress/block-library
Version:
Block library for the WordPress editor.
26 lines (23 loc) • 514 B
JavaScript
/**
* WordPress dependencies
*/
import { useBlockProps } from '@wordpress/block-editor';
/**
* Internal dependencies
*/
import TableOfContentsList from './list';
import { linearToNestedHeadingList } from './utils';
export default function save( { attributes: { headings = [] } } ) {
if ( headings.length === 0 ) {
return null;
}
return (
<nav { ...useBlockProps.save() }>
<ol>
<TableOfContentsList
nestedHeadingList={ linearToNestedHeadingList( headings ) }
/>
</ol>
</nav>
);
}