How to use the slugify function in slugify

To help you get started, we’ve selected a few slugify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github processing / p5.js-web-editor / server / config / passport.js View on Github external
User.findOne({ username }, (findByUsernameErr, existingUsernameUser) => {
        if (existingUsernameUser) {
          const adj = friendlyWords.predicates[Math.floor(Math.random() * friendlyWords.predicates.length)];
          username = slugify(`${username} ${adj}`);
        }
        // what if a username is already taken from the display name too?
        // then, append a random friendly word?
        if (existingEmailUser) {
          existingEmailUser.email = existingEmailUser.email || primaryEmail;
          existingEmailUser.google = profile._json.emails[0].value;
          existingEmailUser.username = existingEmailUser.username || username;
          existingEmailUser.tokens.push({ kind: 'google', accessToken });
          existingEmailUser.name = existingEmailUser.name || profile._json.displayName;
          existingEmailUser.verified = User.EmailConfirmation.Verified;
          existingEmailUser.save((saveErr) => {
            if (saveErr) {
              console.log(saveErr);
            }
            done(null, existingEmailUser);
          });
github FormidableLabs / react-native-interactions-workshop / app / src / data / index.js View on Github external
.trim()
          .replace('\n', '<p>')
          .replace(/\s+/g, ' ')
          .replace(/<br>/g, '\n')
          .replace(/</p><p>/g, '\n\n')
      : null;

    const duration = event.duration || 0.5; // in hours
    const profile = speaker ? speakerLookup[slugify(speaker)] : undefined;
    const isTalk = !!profile;

    if (!date || (!title &amp;&amp; !speaker)) {
      return null;
    }
    return {
      slug: slugify(`${title} ${getTime(date)}`),
      title: title || speaker,
      isTalk,
      speaker: isTalk ? speaker : null,
      profile,
      company,
      agenda,
      date,
      duration
    };
  })
  .filter(Boolean);
</p>
github reactioncommerce / reaction-devtools / data / methods.js View on Github external
async function addTags() {
  let numOfTags = settings.tags;
  const linkedTagsRatio = 0.2;
  const topLevelRatio = 0.1;
  let batch = Tags.initializeUnorderedBulkOp({useLegacyOps: true});
  for (let i = 0; i &lt; numOfTags; i++) {
    const data = _.cloneDeep(tagTemplate);
    data._id = randomID(10, "aA0");
    data.name = `${faker.commerce.department()}-${randomID(4, 'aA0')}`;
    data.slug = slugify(data.name);
    data.createdAt = new Date();
    data.updatedAt = new Date();
    if (i === Math.round(numOfTags * topLevelRatio)) {
      data.isTopLevel = true
      tags.push(data._id);
    }
    batch.insert(data);
  }
  await batch.execute();
  batch = Tags.initializeUnorderedBulkOp({useLegacyOps: true});
  const linkedTags = numOfTags * linkedTagsRatio;
  for (let i = 0; i &lt; linkedTags; i++) {
    const currentTag = tags[Math.floor(Math.random() * tags.length)]
    const start = Math.floor(Math.random() * tags.length);
    const len = Math.floor(Math.random() * 5);
    const end = (start + len) &gt; tags.length ? tags.length : (start + len)
github lumen-cms / lumen-cms / lib / templates / components / edit / LcArticleListDialog.vue View on Github external
async onSave () {
        let mutation = createGql;
        const variables = {
          title: this.inputField,
          languageKey: this.$store.state.lc.locale.toUpperCase(),
          slug: slugify(this.inputField, { lower: true })
        };
        if (this.selected) {
          variables.id = this.selected;
          mutation = updateGql;
        }
        await this.mutateGql(
          {
            mutation,
            variables,
            refetchQueries: ['allArticleCategories']
          },
          this.selected ? 'updateArticleCategory' : 'createArticleCategory'
        );
      },
      toggleShow () {
github philsturgeon / awesome-earth / src / templates / category.jsx View on Github external
{(link.countries || []).map(code =&gt; {
                                    const country = Countries.fromAlpha2Code(
                                      code.toUpperCase()
                                    );
                                    return (
                                      <span title="{country.name}">
                                        {country.emoji}
                                      </span>
                                    );
                                  })}
github govau / design-system-site / src / layout / component / screenreader.js View on Github external
const Screenreader = ({ headline, speak, _body, _ID, _parseMD, _relativeURL }) =&gt; (
	<div>
		<div>
			<a href="{`#${">#</a>

			<h2>
				{ headline }
			</h2>

			<div>
				<div>
					{ _parseMD( speak ) }
				</div>
			</div>
			<div>
				{ _body }
			</div>
		</div>
	</div>
);
github markusenglund / react-kanban / src / app / components / Home / BoardAdder.jsx View on Github external
const { title } = this.state;
    if (title === "") {
      return;
    }
    const { dispatch, history, userId } = this.props;
    const boardId = shortid.generate();
    dispatch({
      type: "ADD_BOARD",
      payload: {
        boardTitle: title,
        boardId,
        userId
      }
    });

    const urlSlug = slugify(title, { lower: true });
    history.push(`/b/${boardId}/${urlSlug}`);

    this.setState({ isOpen: false, title: "" });
  };
github 0xProject / 0x-monorepo / packages / website / ts / utils / algolia_helpers.ts View on Github external
formattedTextNodes.forEach((node: FormattedNode, index: number) => {
        const titleSlug = slugify(metaData.title, { lower: true });

        content.push({
            ...metaData,
            url,
            urlWithHash: url + node.hash,
            hash: node.hash,
            textContent: node.textContent,
            id: titleSlug,
            objectID: `${titleSlug}_${index}`,
        });
    });

slugify

Slugifies a String

MIT
Latest version published 1 year ago

Package Health Score

82 / 100
Full package analysis