How to use the @teleporthq/teleport-shared.UIDLUtils.prefixAssetsPath function in @teleporthq/teleport-shared

To help you get started, we’ve selected a few @teleporthq/teleport-shared 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 teleporthq / teleport-code-generators / packages / teleport-plugin-common / src / builders / ast-builders.ts View on Github external
assets.forEach((asset) => {
    const assetPath = UIDLUtils.prefixAssetsPath(options.assetsPrefix, asset.path)

    // link canonical for SEO
    if (asset.type === 'canonical' && assetPath) {
      const linkTag = createJSXTag('link')
      addAttributeToJSXTag(linkTag, 'rel', 'canonical')
      addAttributeToJSXTag(linkTag, 'href', assetPath)
      addChildJSXTag(headNode, linkTag)
    }

    // link stylesheet (external css, font)
    if ((asset.type === 'style' || asset.type === 'font') && assetPath) {
      const linkTag = createJSXTag('link')
      addAttributeToJSXTag(linkTag, 'rel', 'stylesheet')
      addAttributeToJSXTag(linkTag, 'href', assetPath)
      addChildJSXTag(headNode, linkTag)
    }
github teleporthq / teleport-code-generators / packages / teleport-project-generator / src / file-handlers.ts View on Github external
assets.forEach((asset) => {
    const assetPath = UIDLUtils.prefixAssetsPath(assetsPrefix, asset.path)

    // link canonical for SEO
    if (asset.type === 'canonical' && assetPath) {
      const linkTag = HASTBuilers.createHTMLNode('link')
      HASTUtils.addAttributeToNode(linkTag, 'rel', 'canonical')
      HASTUtils.addAttributeToNode(linkTag, 'href', assetPath)
      HASTUtils.addChildNode(headNode, linkTag)
    }

    // link stylesheet (external css, font)
    if ((asset.type === 'style' || asset.type === 'font') && assetPath) {
      const linkTag = HASTBuilers.createHTMLNode('link')
      HASTUtils.addAttributeToNode(linkTag, 'rel', 'stylesheet')
      HASTUtils.addAttributeToNode(linkTag, 'href', assetPath)
      HASTUtils.addChildNode(headNode, linkTag)
    }
github teleporthq / teleport-code-generators / packages / teleport-uidl-resolver / src / utils.ts View on Github external
const staticContent = styleValue.content
        if (typeof staticContent === 'number') {
          acc[styleKey] = styleValue
          return acc
        }

        if (
          typeof staticContent === 'string' &&
          STYLE_PROPERTIES_WITH_URL.includes(styleKey) &&
          staticContent.includes(Constants.ASSETS_IDENTIFIER)
        ) {
          // split the string at the beginning of the ASSETS_IDENTIFIER string
          const startIndex = staticContent.indexOf(Constants.ASSETS_IDENTIFIER) - 1 // account for the leading '/'
          const newStyleValue =
            staticContent.slice(0, startIndex) +
            UIDLUtils.prefixAssetsPath(
              assetsPrefix,
              staticContent.slice(startIndex, staticContent.length)
            )
          acc[styleKey] = {
            type: 'static',
            content: newStyleValue,
          }
        } else {
          acc[styleKey] = styleValue
        }
        return acc
      case 'nested-style':
        acc[styleKey] = styleValue
        acc[styleKey].content = prefixAssetURLs(styleValue.content, assetsPrefix)
        return acc
    }
github teleporthq / teleport-code-generators / packages / teleport-project-generator-next / src / utils.ts View on Github external
Object.keys(metaItem).forEach((key) => {
      const metaValue = UIDLUtils.prefixAssetsPath(options.assetsPrefix, metaItem[key])
      ASTUtils.addAttributeToJSXTag(metaTag, key, metaValue)
    })
    ASTUtils.addChildJSXTag(headNode, metaTag)
github teleporthq / teleport-code-generators / packages / teleport-project-generator / src / file-handlers.ts View on Github external
const icons = manifest.icons.map((icon) => {
    const src = UIDLUtils.prefixAssetsPath(assetsPrefix || '', icon.src)
    return { ...icon, src }
  })
github teleporthq / teleport-code-generators / packages / teleport-uidl-resolver / src / utils.ts View on Github external
Object.keys(originalElement.attrs).forEach((attrKey) => {
      const attrValue = originalElement.attrs[attrKey]
      if (attrValue.type === 'static' && typeof attrValue.content === 'string') {
        originalElement.attrs[attrKey].content = UIDLUtils.prefixAssetsPath(
          assetsPrefix,
          attrValue.content
        )
      }
    })
  }
github teleporthq / teleport-code-generators / packages / teleport-project-generator-gatsby / src / utils.ts View on Github external
Object.keys(metaItem).forEach((key) => {
      const metaValue = UIDLUtils.prefixAssetsPath(options.assetsPrefix, metaItem[key])
      ASTUtils.addAttributeToJSXTag(metaTag, key, metaValue)
    })
    ASTUtils.addChildJSXTag(headNode, metaTag)
github teleporthq / teleport-code-generators / packages / teleport-project-generator / src / file-handlers.ts View on Github external
Object.keys(metaItem).forEach((key) => {
      const prefixedURL = UIDLUtils.prefixAssetsPath(assetsPrefix, metaItem[key])
      HASTUtils.addAttributeToNode(metaTag, key, prefixedURL)
    })
    HASTUtils.addChildNode(headNode, metaTag)
github teleporthq / teleport-code-generators / packages / teleport-uidl-resolver / src / utils.ts View on Github external
Object.keys(tag).forEach((key) => {
      tag[key] = UIDLUtils.prefixAssetsPath(options.assetsPrefix, tag[key])
    })
  })