createTemplateOptions = (options, trailingSlash) => {
  let templatePath = options.path
  let createPath = () => null

  const routeKeys = []

  if (typeof templatePath === 'string') {
    templatePath = templatePath.replace(/\/+/g, '/')

    if (trailingSlash) {
      templatePath = trimEnd(templatePath, '/') + '/'
    }

    createPath = pathToRegexp.compile(templatePath)
    pathToRegexp(templatePath, routeKeys)
  }

  return {
    createPath,
    name: options.name || 'default',
    path: templatePath,
    typeName: options.typeName,
    component: options.component,
    from: options.from || FROM_CONFIG,
    routeKeys: routeKeys
      .filter(key => typeof key.name === 'string')
      .map(key => {
        // separate field name from suffix
        const [, fieldName, suffix] = (
          key.name.match(/^(.*[^_])_([a-z]+)$/) ||
          [null, key.name, null]
        )

        const path = fieldName.split('__')

        return {
          name: key.name,
          path,
          fieldName,
          repeat: key.repeat,
          suffix
        }
      })
  }
}
Param values are slugified but the original
value will be available with '_raw' suffix.