How to use the hexo-util.htmlTag function in hexo-util

To help you get started, we’ve selected a few hexo-util 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 minamo173 / hexo-tag-link-preview / linkPreview.js View on Github external
}

        descriptions += util.htmlTag('div', { class: 'og-title' }, escapeHTML(ogp.ogTitle))

        // Description
        if (config.description && ogp.hasOwnProperty('ogDescription')) {
          let description = ogp.ogDescription

          if (description && description.length > config.descriptionLength) {
            description = description.slice(0, config.descriptionLength) + '…'
          }

          descriptions += util.htmlTag('div', { class: 'og-description' }, escapeHTML(description))
        }

        descriptions = util.htmlTag('div', { class: 'descriptions' }, descriptions)

        const tag = util.htmlTag('div', { class: 'link-area' }, image + descriptions)

        return util.htmlTag('a', { href: url, class: config.className, target: config.target, rel: config.rel }, tag)
      })
      .catch(function (error) {
github cypress-io / cypress / docs / scripts / tags.js View on Github external
hexo.extend.tag.register('issue', function (args) {
  // {% issue 74 'not currently supported' %}

  const num = args[0]

  const attrs = {
    href: `https://github.com/cypress-io/cypress/issues/${num}`,
    target: '_blank',
  }

  const text = args[1] || `issue #${num}`

  return util.htmlTag('a', attrs, text)
})
github minamo173 / hexo-tag-link-preview / linkPreview.js View on Github external
// Description
        if (config.description && ogp.hasOwnProperty('ogDescription')) {
          let description = ogp.ogDescription

          if (description && description.length > config.descriptionLength) {
            description = description.slice(0, config.descriptionLength) + '…'
          }

          descriptions += util.htmlTag('div', { class: 'og-description' }, escapeHTML(description))
        }

        descriptions = util.htmlTag('div', { class: 'descriptions' }, descriptions)

        const tag = util.htmlTag('div', { class: 'link-area' }, image + descriptions)

        return util.htmlTag('a', { href: url, class: config.className, target: config.target, rel: config.rel }, tag)
      })
      .catch(function (error) {
github hexojs / hexo / test / scripts / helpers / open_graph.js View on Github external
function meta(options) {
    return tag('meta', options);
  }
github hexojs / hexo / lib / plugins / helper / open_graph.js View on Github external
function og(name, content) {
  return `${htmlTag('meta', {
    property: name,
    content
  })}\n`;
}
github minamo173 / hexo-tag-link-preview / index.js View on Github external
if (ogp.hasOwnProperty('ogImage')) {
        image += util.htmlTag('img', { src: ogp.ogImage.url } , '');
        image = util.htmlTag('div', { class: 'og-image'}, image)
      }

      descriptions += util.htmlTag('div', { class: 'og-title' }, escapeHTML(ogp.ogTitle));

      if (ogp.hasOwnProperty('ogDescription')) {
        const description = adjustLength(ogp.ogDescription);
        descriptions += util.htmlTag('div', { class: 'og-description' }, escapeHTML(description));
      }

      descriptions = util.htmlTag('div', { class: 'descriptions' }, descriptions);

      const tag = util.htmlTag('div', { class: 'link-area' },  image + descriptions);
      return util.htmlTag('a', { href: options.url, class: className, target: options.target, rel: options.rel }, tag);
    })
    .catch(function (error) {
github m80126colin / hexo-tag-owl / images / local.js View on Github external
module.exports = function (args, root) {
  var img_path = args[0];
  var config  = {
    src: root + img_path
  }
  return '<div class="owl-media owl-image owl-local">' + util.htmlTag('img', config) + '</div>';
}
github hexojs / hexo / lib / plugins / helper / open_graph.js View on Github external
result += meta('twitter:image', images[0]);
  }

  if (options.twitter_id) {
    let twitterId = options.twitter_id;
    if (twitterId[0] !== '@') twitterId = `@${twitterId}`;

    result += meta('twitter:creator', twitterId);
  }

  if (options.twitter_site) {
    result += meta('twitter:site', options.twitter_site);
  }

  if (options.google_plus) {
    result += `${htmlTag('link', {rel: 'publisher', href: options.google_plus})}\n`;
  }

  if (options.fb_admins) {
    result += og('fb:admins', options.fb_admins);
  }

  if (options.fb_app_id) {
    result += og('fb:app_id', options.fb_app_id);
  }

  return result.trim();
}
github m80126colin / hexo-tag-owl / lib / tag / images / local.js View on Github external
module.exports = function (hexo, args) {
  var config = { src: hexo.config.root + args[0] }
  return '<div class="owl-media owl-image owl-local">' + util.htmlTag('img', config) + '</div>';
}