How to use the hexo-util.url_for.call 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 hexojs / hexo / lib / plugins / tag / img.js View on Github external
return function imgTag(args, content) {
    const classes = [];
    let src, width, height, title, alt;

    // Find image URL and class name
    while (args.length > 0) {
      const item = args.shift();
      if (rUrl.test(item) || item[0] === '/') {
        src = url_for.call(ctx, item);
        break;
      } else {
        classes.push(item);
      }
    }

    // Find image width and height
    if (args && args.length) {
      if (!/\D+/.test(args[0])) {
        width = args.shift();

        if (args.length && !/\D+/.test(args[0])) {
          height = args.shift();
        }
      }
github hexojs / hexo-generator-feed / lib / autodiscovery.js View on Github external
function autodiscoveryInject(data) {
  const { config } = this;
  const { feed } = config;
  const { path, type } = feed;
  let autodiscoveryTag = '';

  if (data.match(/type=['|"]?application\/(atom|rss)\+xml['|"]?/i) || feed.autodiscovery === false) return;

  if (typeof type === 'string') {
    autodiscoveryTag += `\n`;
  } else {
    type.forEach((feedType, i) => {
      autodiscoveryTag += `\n`;
    });
  }

  return data.replace(/(?!<\/head>).+?<\/head>/s, str => str.replace('', `${autodiscoveryTag}`));
}
github hexojs / hexo-generator-feed / lib / autodiscovery.js View on Github external
type.forEach((feedType, i) => {
      autodiscoveryTag += `\n`;
    });
  }
github hexojs / hexo-renderer-marked / lib / renderer.js View on Github external
image(href, title, text) {
    const { options } = this;

    if (!parse(href).hostname && !options.config.relative_link
      && options.prependRoot) {
      href = url_for.call(options, href);
    }

    let out = `