Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "hexo in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'hexo' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

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}`);
      }
    })();
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);

    if (!result.data_prefix) result.data_prefix = result.data_dir;

    // attach disqus script
    if (result.comments &amp;&amp; result.comments.disqus) {
      const disqus = result.comments.disqus;
      disqus.script = disqus.script || `//${disqus.shortname}.disqus.com/embed.js`;
      delete disqus.shortname;
    }

    // convert menu to array
hexo.on('generateBefore', function () {
    const site = hexo.config;
    const theme = hexo.theme.config;
    const email = theme.profile &amp;&amp; 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);
describe('structured_data', function () {
  const Hexo = require('hexo');
  const hexo = new Hexo();
  const ctx = {
    url_for: urlFor.bind(hexo),
    config: hexo.config,
    theme: { profile: {}, sns: {} }
  };
  const structuredData = require('../../../lib/helper/structured_data').bind(ctx);

  it('generate WebSite entry', function () {
    const $ = cheerio.load(structuredData({}));
    const json = JSON.parse($('script').html());

    expect(json.length).toBe(1);
    expect(json[0]['@type']).toBe('WebSite');
  });

  it('generate additional Article entry for post page', function () {
    const $ = cheerio.load(structuredData({ type: 'post', categories: { toArray() { return [] } } }));
    const json = JSON.parse($('script').html());
describe('theme_static', function () {
  const Hexo = require('hexo');
  const hexo = new Hexo();
  const ctx = {
    url_for: urlFor.bind(hexo),
    config: hexo.config,
    theme: { theme: {} }
  };
  const themeStatic = require('../../../lib/helper/theme_static').bind(ctx);

  it('css', function () {
    const $ = cheerio.load(themeStatic('css'));
    expect($('link').eq(0).attr('href')).toMatch(/^\/styles\.\w*\.css$/);
  });

  it('js', function () {
    const $ = cheerio.load(themeStatic('js'));
    expect($('script').eq(0).attr('src')).toMatch(/^\/runtime/);
    expect($('script').eq(1).attr('src')).toMatch(/^\/polyfills/);
    expect($('script').eq(2).attr('src')).toMatch(/^\/polyfills/);
    expect($('script').eq(3).attr('src')).toMatch(/^\/main/);
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)
    };
  });
}
...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)
      };
    }),
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}
   */
module.exports = hexo => {
    const RESERVED_KEYS = {
        post: Object.keys(require('hexo/lib/models/post')(hexo).paths),
        page: Object.keys(require('hexo/lib/models/page')(hexo).paths)
    };

    function getThemeConfig(extension) {
        if (fs.existsSync(path.join(hexo.theme_dir, '_config' + extension + '.yml'))) {
            return yaml.safeLoad(fs.readFileSync(path.join(hexo.theme_dir, '_config' + extension + '.yml')));
        }
        return null;
    }

    const ALTERNATIVE_CONFIG = {
        post: getThemeConfig('.post'),
        page: getThemeConfig('.page')
    }

    function getExtraConfig(source, reservedKeys) {
        const result = {};
module.exports = hexo => {
    const RESERVED_KEYS = {
        post: Object.keys(require('hexo/lib/models/post')(hexo).paths),
        page: Object.keys(require('hexo/lib/models/page')(hexo).paths)
    };

    function getThemeConfig(extension) {
        if (fs.existsSync(path.join(hexo.theme_dir, '_config' + extension + '.yml'))) {
            return yaml.safeLoad(fs.readFileSync(path.join(hexo.theme_dir, '_config' + extension + '.yml')));
        }
        return null;
    }

    const ALTERNATIVE_CONFIG = {
        post: getThemeConfig('.post'),
        page: getThemeConfig('.page')
    }

    function getExtraConfig(source, reservedKeys) {

Is your System Free of Underlying Vulnerabilities?
Find Out Now