Files
outline/frontend/components/Editor/headingToSlug.js
Tom Moor 23c95f4d56 Fixes: JS error when no heading
Fixes: Reduce hover zone
Fixes: Add H1s into TOC
2017-10-24 08:43:35 -07:00

10 lines
270 B
JavaScript

// @flow
import { escape } from 'lodash';
import type { Node } from './types';
import slug from 'slug';
export default function headingToSlug(node: Node) {
const level = node.type.replace('heading', 'h');
return escape(`${level}-${slug(node.text)}-${node.key}`);
}