frontend > app
This commit is contained in:
9
app/components/Editor/headingToSlug.js
Normal file
9
app/components/Editor/headingToSlug.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// @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}`);
|
||||
}
|
||||
Reference in New Issue
Block a user