How to use the @sanity/generate-help-url function in @sanity/generate-help-url

To help you get started, we’ve selected a few @sanity/generate-help-url 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 sanity-io / sanity / packages / @sanity / form-builder / src / FormBuilderInput.tsx View on Github external
const {type} = this.props
    if (this._input && typeof this._input.focus === 'function') {
      this._input.focus()
      return
    }
    const inputComponent = this.resolveInputComponent(type)
    const inputDisplayName = getDisplayName(inputComponent)
    // no ref
    if (!this._input) {
      // eslint-disable-next-line no-console
      console.warn(
        'The input component for type "%s" has no associated ref element. Please check the implementation of "%s" [%O]. If this is a function component, it must be wrapped in React.forwardRef(). Read more at %s',
        type.name,
        inputDisplayName,
        inputComponent,
        generateHelpUrl('input-component-no-ref')
      )
      return
    }
    // eslint-disable-next-line no-console
    console.warn(
      'The input component for type "%s" is missing a required ".focus()" method. Please check the implementation of "%s" [%O]. Read more at %s',
      type.name,
      inputDisplayName,
      inputComponent,
      generateHelpUrl('input-component-missing-required-method')
    )
  }
github sanity-io / sanity / packages / @sanity / form-builder / src / FormBuilderInput.tsx View on Github external
console.warn(
        'The input component for type "%s" has no associated ref element. Please check the implementation of "%s" [%O]. If this is a function component, it must be wrapped in React.forwardRef(). Read more at %s',
        type.name,
        inputDisplayName,
        inputComponent,
        generateHelpUrl('input-component-no-ref')
      )
      return
    }
    // eslint-disable-next-line no-console
    console.warn(
      'The input component for type "%s" is missing a required ".focus()" method. Please check the implementation of "%s" [%O]. Read more at %s',
      type.name,
      inputDisplayName,
      inputComponent,
      generateHelpUrl('input-component-missing-required-method')
    )
  }
github sanity-io / sanity / packages / @sanity / resolver / src / resolver.js View on Github external
const current = `"${plugin.name}" (${plugin.path})`
    throw new Error(
      `${`Plugin ${current} tries to implement a part "${partName}",` +
        ' but did not define a path. Did you mean to use "name"?\n' +
        'See '}${generateHelpUrl('part-declare-vs-implement')}`
    )
  }

  const prevDefinition = definitions[partName]
  if (prevDefinition && !prevDefinition.isAbstract) {
    const existing = `"${prevDefinition.plugin}" (${prevDefinition.path})`
    const current = `"${plugin.name}" (${plugin.path})`
    throw new Error(
      `${`Plugin ${current} tried to implement part "${partName}", which is already declared` +
        ` as a non-overridable part by ${existing} - ` +
        'See '}${generateHelpUrl('implement-non-overridable-part')}`
    )
  } else if (!prevDefinition) {
    // In some cases, a user might want to declare a new part name and
    // assign it a non-overridable implementation, while simulatenously
    // fulfilling an existing part using `implements`. In this case,
    // `name`, `implements` and `path` are all set, and we want the part
    // referenced in `implements` to be treated as a non-abstract part.
    // This is why we're explicitly setting `isAbstract` to true below
    // `loose` means that this declaration is "implicit" - the part isn't
    // defined as a `name` + `description` combination, so if we come across
    // a plugin that declares the part outright, we want to use that over this
    definitions[partName] = getDefinitionDeclaration(plugin, part, {
      isAbstract: true,
      loose: true
    })
  }
github sanity-io / sanity / packages / @sanity / resolver / src / resolver.js View on Github external
function assignNonOverridablePart(plugin, part, implementations, definitions, options) {
  // Actual, non-overridable part
  const prevDefinition = definitions[part.name]
  if (prevDefinition) {
    // Part already exists, non-overridable parts can't be redefined
    const existing = `"${prevDefinition.plugin}" (${prevDefinition.path})`
    const current = `"${plugin.name}" (${plugin.path})`
    throw new Error(
      `${`Plugins ${existing} and ${current} both define part "${part.name}"` +
        ' - did you mean to use "implements"?\n' +
        'See '}${generateHelpUrl('part-declare-vs-implement')}`
    )
  }

  definitions[part.name] = getDefinitionDeclaration(plugin, part)
  implementations[part.name] = [getImplementationDeclaration(plugin, part, options)]
}
github sanity-io / sanity / packages / @sanity / resolver / src / validateManifest.js View on Github external
function validatePartName(name, baseError) {
  const examples = [
    'Examples:',
    '- part:package-name/part-name',
    '- part:package-name/part-name-style',
    '',
    `See ${generateHelpUrl('part-name-format')}`
  ].join('\n')

  if (name.indexOf('all:') !== -1) {
    throw new Error(`${baseError}\nPart "${name}" is invalid - can't contain "all:". ${examples}`)
  }

  if (matchers.partMultiPrefixed.test(name)) {
    throw new Error(
      `${baseError}\nPart "${name}" is invalid - can't contain multiple ":". ${examples}`
    )
  }

  if (!matchers.partPrefix.test(name)) {
    throw new Error(
      `${baseError}\nPart "${name}" is invalid - it needs a "part:"-prefix. ${examples}`
    )
github sanity-io / sanity / packages / @sanity / resolver / src / readManifest.js View on Github external
function handleManifestReadError(err, options) {
  if (err.code === 'ENOENT' && options.plugin) {
    const base = `No "sanity.json" file found in plugin "${options.plugin}"`
    const help = `See ${generateHelpUrl('missing-plugin-sanity-json')}`
    throw new Error(`${base}\n${help}`)
  } else if (err.name === 'ValidationError' && options.plugin) {
    err.message = `Error while reading "${options.plugin}" manifest:\n${err.message}`
  } else if (err.name === 'ValidationError') {
    err.message = `Error while reading "${options.basePath}/sanity.json":\n${err.message}`
  }

  throw err
}
github sanity-io / sanity / packages / @sanity / resolver / src / validateManifest.js View on Github external
if (isImplementation && !hasPart) {
      throw new Error(
        [
          baseError,
          'A part that has a defined `path` needs to also define either `name` or `implements`',
          `See ${generateHelpUrl('plugin-parts-syntax')}`
        ].join('\n')
      )
    }

    if (!isDefined(part.path) && !isDefined(part.description)) {
      throw new Error(
        [
          baseError,
          'A part that has not defined a `path` needs to include a `description`',
          `See ${generateHelpUrl('plugin-parts-syntax')}`
        ].join('\n')
      )
    }

    if (isDefined(part.name)) {
      validatePartName(part.name, baseError)
    }

    if (isDefined(part.implements)) {
      validatePartName(part.implements, baseError)
    }

    if (isDefined(part.description)) {
      validateDescription(part.description, baseError)
    }
  })

@sanity/generate-help-url

Generates URLs to specific sections of the Sanity documentation

MIT
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis

Popular @sanity/generate-help-url functions