mirror of
https://github.com/shoelace-style/shoelace.git
synced 2026-01-12 02:59:13 +00:00
17 lines
449 B
JavaScript
17 lines
449 B
JavaScript
import slugify from 'slugify';
|
|
|
|
/** Creates a slug from an arbitrary string of text. */
|
|
export function createSlug(text) {
|
|
return slugify(String(text), {
|
|
remove: /[^\w|\s]/g,
|
|
lower: true
|
|
});
|
|
}
|
|
|
|
/** Determines whether or not a link is external. */
|
|
export function isExternalLink(link) {
|
|
// We use the "internal" hostname when initializing JSDOM so we know that those are local links
|
|
if (!link.hostname) return false;
|
|
return true;
|
|
}
|