How to use the hexo/lib/plugins/helper/date.date.bind 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 / filter / post.js View on Github external
if (data.layout !== 'page' && data.layout !== 'post') return;

  const config = this.config;
  const theme = this.theme.config;
  const isPage = data.layout === 'page';

  if (hasComments === undefined)
    hasComments = !!(theme.comments || theme.plugins && theme.plugins.comments);
  if (hasReward === undefined)
    hasReward = !!theme.reward;
  if (hasToc === undefined)
    hasToc = !!theme.toc;
  if (copyright === undefined)
    copyright = theme.copyright;
  if (dateHelper === undefined)
    dateHelper = date.bind({ page: { lang: localeId(config.language, true) }, config })
  if (uriReplacer === undefined) {
    uriReplacer = (() => {
      let assetsFn = src => src;
      if (theme.assets) {
        const prefix = theme.assets.prefix ? theme.assets.prefix + '/' : ''
        const suffix = theme.assets.suffix || ''
        assetsFn = src => prefix + `${src}${suffix}`.replace(/\/{2,}/g, '/')
      }

      return (src, assetPath) => {
        assetPath = assetPath ? assetPath + '/' : ''

        // skip both external and absolute path
        return /^(\/\/?|http|data\:image)/.test(src) ? src : assetsFn(`${assetPath}${src}`);
      }
    })();
github ikeq / hexo-theme-inside / lib / generator / entries / archives.js View on Github external
module.exports = function ({ site, theme, locals, helpers }) {
  const posts = locals.posts.map(pick(archiveProps));
  const config = theme.archive;
  const dateHelper = date.bind({ page: { lang: localeId(site.language, true) }, config })

  if (!posts.length) return [];

  return flattenDeep(
    helpers.pagination.apply(posts, { perPage: config.per_page, id: 'archives' }, [
      { type: 'json', dataFn: classify },
      { type: 'html', extend: { type: 'archives' } },
    ])
  );

  /**
   * Classify posts with `year` and `month`
   *
   * @param {object} data
   * @returns {data}
   */