How to use the transliteration.slugify function in transliteration

To help you get started, we’ve selected a few transliteration 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 Dragory / modmailbot / src / threads.js View on Github external
return jsonDb.get('threads', []).then(threads => {
    const thread = threads.find(t => t.userId === user.id);
    if (thread) return thread;

    // If we didn't find an existing modmail thread, attempt creating one
    if (! allowCreate) return null;

    // Channel names are particularly picky about what characters they allow...
    let cleanName = transliterate.slugify(user.username);
    if (cleanName === '') cleanName = 'unknown';
    cleanName = cleanName.slice(0, 95); // Make sure the discrim fits

    const channelName = `${cleanName}-${user.discriminator}`;

    if (originalMessage && originalMessage.cleanContent && config.ignoreAccidentalThreads) {
      const cleaned = originalMessage.cleanContent.replace(/[^a-z\s]/gi, '').toLowerCase().trim();
      if (accidentalThreadMessages.includes(cleaned)) {
        console.log('[NOTE] Skipping thread creation for message:', originalMessage.cleanContent);
        return null;
      }
    }

    console.log(`[NOTE] Creating new thread channel ${channelName}`);
    return getUtils().getInboxGuild().createChannel(`${channelName}`)
      .then(channel => {
github Dragory / modmailbot / src / modules / move.js View on Github external
commands.addInboxThreadCommand('move', '', async (msg, args, thread) => {
    const searchStr = args.category;
    const normalizedSearchStr = transliterate.slugify(searchStr);

    const categories = msg.channel.guild.channels.filter(c => {
      // Filter to categories that are not the thread's current parent category
      return (c instanceof Eris.CategoryChannel) && (c.id !== msg.channel.parentID);
    });

    if (categories.length === 0) return;

    // See if any category name contains a part of the search string
    const containsRankings = categories.map(cat => {
      const normalizedCatName = transliterate.slugify(cat.name);

      let i = 0;
      do {
        if (! normalizedCatName.includes(normalizedSearchStr.slice(0, i + 1))) break;
        i++;
github fuuka1 / QiNA / src / runner / MainConnector.js View on Github external
err: '未配置'
        }
        event.sender.send('qina', returnMsg) 
        return false;
      }
  
      if (val.Access == null || val.Bucket == null || val.Domain == null || val.Secret == null) {
        returnMsg = {
          state: false,
          err: '配置不全'
        }
        event.sender.send('qina', returnMsg)
        return false;
      }
  
      var key = transliteration.slugify(arg.Name) + '(' + moment().format() + ')' + path.extname(arg.Name);
      var filePath = path.normalize(arg.Path);
  
      var client = qn.create({
        accessKey: val.Access,
        secretKey: val.Secret,
        bucket: val.Bucket,
        origin: val.Domain,
      });
  
      console.log('qn 开始上传');
      client.uploadFile(filePath, {
        key: key
      }, function(err, ret) {
        console.log(ret);
  
        if (!err) {
github reactioncommerce / reaction / imports / plugins / core / core / server / Reaction / getSlug.js View on Github external
export default function getSlug(slugString) {
  return (typeof slugString === "string" && slugify(slugString)) || "";
}
github koahubjs / koahub-simple-cms / app / controller / admin / article.controller.js View on Github external
async add() {

        if (this.isPost()) {

            const article = this.post;

            article.pinyin = slugify(article.title);

            await this.model('article').add(article);

            this.json('/admin/article/index', '保存成功');
        } else {

            if (this.query.id) {
                var article = await this.model('article', {withRelated: ['file']}).find({id: this.query.id});
                await this.render('article_add', {article: article});
            } else {
                await this.render('article_add');
            }
        }
    }
}
github museui / muse-ui / docs / build / gen-indices.js View on Github external
indices = indices.concat(matches.map(match => {
          const isComponent = match[0].indexOf('##') < 0;
          const title = match[0].replace(/#{1,4}/, '').trim();
          const index = { component: getComponentName(component), title };
          index.ranking = isComponent ? 2 : 1;
          index.anchor = slugify(title);
          index.content = (match[1] || title).replace(/<[^>]+>/g, '');
          return index;
        }));
      });
github koahubjs / koahub-simple-cms / app / controller / admin / page.controller.js View on Github external
async add() {

        if (this.isPost()) {

            const page = this.post;
            page.pinyin = slugify(page.name);

            await this.model('page').add(page);

            this.json('/admin/page/index', '保存成功');

        } else {

            if (this.query.id) {
                var page = await this.model('page').find({id: this.query.id});
                await this.render('page_add', {page: page});
            } else {
                await this.render('page_add');
            }


        }
github openstf / stf / lib / units / device / plugins / util / urlformat.js View on Github external
function createSlug() {
      var model = identity.model
      var name = data ? data.name.id : ''

      return (name === '' || model.toLowerCase() === name.toLowerCase()) ?
        tr.slugify(model) :
        tr.slugify(name + ' ' + model)
    }
github openstf / stf / lib / units / device / plugins / util / urlformat.js View on Github external
function createSlug() {
      var model = identity.model
      var name = data ? data.name.id : ''

      return (name === '' || model.toLowerCase() === name.toLowerCase()) ?
        tr.slugify(model) :
        tr.slugify(name + ' ' + model)
    }
github youzan / zent / site / src / components / markdown / heading.js View on Github external
export function H4(props) {
  const { children } = props;
  const id = slugify(children);

  return (
    <h4>
      <a href="{`#${id}`}"></a>
      <a id="{id}">
      {children}
    </a></h4><a id="{id}">
  );
}
</a>

transliteration

Unicode to ACSII transliteration / slugify module for node.js, browser, Web Worker, ReactNative and CLI.

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis