recital / exporters / ink / src / utils / slugify.ts
slugify.ts
Raw
/**
 * Copyright (c) 2022 Amorphous
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

import { slugify } from "@a-morphous/recital-ext-common-commands"

export const inkSlugify = (inputText: string): string => {
	if (!inputText) {
		return ''
	}
	if (inputText.startsWith('$')) {
		return inputText.substring(1)
	}
	if (['END', 'DONE'].includes(inputText.toLocaleUpperCase())) {
		return inputText.toLocaleUpperCase()
	} 
	return slugify(inputText).replace(/-/g, '_')
}