How to use hast-util-has-property - 2 common examples

To help you get started, we’ve selected a few hast-util-has-property 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 SAP / luigi / website / docs / src / unified-plugins / rehype-luigi-linkparser.js View on Github external
function modify(node, prop) {
    const githubMaster = 'https://github.com/SAP/luigi/blob/master/';
    if (has(node, prop)) {
      var parsed = url.parse(node.properties[prop]);
      if (
        parsed.href.startsWith(githubMaster + 'docs') && parsed.pathname && parsed.pathname.endsWith('.md') ||
        parsed.pathname && parsed.pathname.endsWith('.md')
      ) {
        // internal link
        // sample links: https://..., file.md, should not start with /file.md or ../file.md
        node.properties['onclick'] = 'navigateInternal(event, this)';
        node.properties['data-linktype'] = 'internal';

        let newHref = parsed.href.replace(githubMaster + 'docs/', '').replace('.md', '');

        // clean ./ from beginning of the link
        if(newHref.startsWith('./')) {
          newHref = newHref.substr(2);
        }
github umijs / father-doc / packages / umi-plugin-father-doc / src / transformer / remark / header.ts View on Github external
visit(ast, 'element', node => {
      if (is(node, headings) && has(node, 'id')) {
        vFile.data.slugs.push({
          depth: parseInt(node.tagName[1], 10) - 1,
          value: toString(node),
          heading: (node.properties as any)?.id,
        });
      }
    });
  } else {

hast-util-has-property

hast utility to check if a node has a property

MIT
Latest version published 1 year ago

Package Health Score

68 / 100
Full package analysis

Popular hast-util-has-property functions