How to use the hexo/lib/plugins/helper/url_for.call function in hexo

To help you get started, we’ve selected a few hexo 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 ikeq / hexo-theme-inside / lib / config.js View on Github external
hexo.on('generateBefore', function () {
    const site = hexo.config;
    const theme = hexo.theme.config;
    const email = theme.profile && theme.profile.email || site.email || '';
    const feed = site.feed ? urlFor.call(this, site.feed.path) : '';
    const result = utils.parseConfig(configSchema, theme, {
      $email: email,
      $feed: feed,
      $copyright: ${new Date().getFullYear()} • <a href="${site.url}">${site.author}</a>`,
      $gravatar: gravatar(email, 160),
      $title: site.title,
      $description: site.description
    });
    const urlFn = result.static_prefix ?
      a =&gt; utils.isExternal(a) ? a : `${result.static_prefix}/${a}` :
      urlFor.bind(this);

    // override default language
    site.language = utils.localeId(site.language);

    const __ = this.theme.i18n.__(site.language);
github ikeq / hexo-theme-inside / lib / generator / api / page.js View on Github external
return pages.map(page => {
    page.link = urlFor.call(this, page.slug);
    page.slug = classifyPage(page, true);
    page.comments = comments && page.comments;

    return {
      index: page.slug,
      type: 'page',
      data: pick(page, pageProps)
    };
  });
}
github ikeq / hexo-theme-inside / lib / generator / api / post.js View on Github external
...posts.map(post => {
      post.link = urlFor.call(this, path.dirname(post.path));
      post.comments = comments && post.comments;

      if (post.toc === undefined || post.toc) {
        const toc = parseToc(post.content, config.toc && config.toc.depth);
        if (toc.length) post.toc = toc;
        else delete post.toc;
      } else delete post.toc;

      return {
        index: post.slug,
        type: 'post',
        data: pick(post, postProps)
      };
    }),