How to use the title.rendered function in title

To help you get started, we’ve selected a few title 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 SoftwareEngineeringDaily / software-engineering-daily-api / server / models / thread.model.js View on Github external
authUser = null,
    sort = 'desc', // asc || desc
    search = null
  } = {}) {
    const query = {};
    let dateDirection = -1;
    if (createdAt) query.createdAt = { $lt: moment(createdAt).toDate() };
    if (sort === 'asc') {
      dateDirection = 1;
      if (createdAt) query.createdAt = { $gt: moment(createdAt).toDate() };
    }

    if (search) {
      const titleSearch = {};
      const searchWords = search.split(' ').join('|');
      titleSearch['title.rendered'] = {
        $regex: new RegExp(`${searchWords}`, 'i')
      };

      // @TODO: Add this when content doesn't have so much extra data
      // let contentSearch = {}
      // contentSearch['content.rendered'] = { $regex: new RegExp(`${search}`, 'i') };

      query.$or = [titleSearch];
    }
    const limitOption = parseInt(limit, 10);
    const orderBy = { createdAt: dateDirection };
    const queryPromise = this.find(query, 'title content author createdAt')
      .populate('author', '-email -password -__v -verified')
      .sort(orderBy)
      .limit(limitOption);
github SoftwareEngineeringDaily / software-engineering-daily-api / server / models / post.model.js View on Github external
let numberOfPages = 0; //eslint-disable-line

    let dateDirection = -1;
    if (createdAtBefore) query.date = { $lt: moment(createdAtBefore).toDate() };
    if (createdAfter) {
      dateDirection = 1;
      query.date = { $gt: moment(createdAfter).toDate() };
    }

    if (tags.length > 0) query.tags = { $all: tags };
    if (categories.length > 0) query.categories = { $all: categories };
    if (topic) query.topics = { $in: topic };
    if (search) {
      const titleSearch = {};
      const searchWords = search.split(' ').join('|');
      titleSearch['title.rendered'] = {
        $regex: new RegExp(`${searchWords}`, 'i')
      };

      // @TODO: Add this when content doesn't have so much extra data
      // let contentSearch = {}
      // contentSearch['content.rendered'] = { $regex: new RegExp(`${search}`, 'i') };

      query.$or = [titleSearch];
    }

    if (transcripts === 'true') {
      query.transcriptUrl = { $exists: true };
    } else if (transcripts === 'false') {
      query.transcriptUrl = { $exists: false };
    }

title

Capitalize your titles properly

MIT
Latest version published 2 days ago

Package Health Score

76 / 100
Full package analysis