1.0.2 • Published 2 years ago

@fengsi/nuxt-robots v1.0.2

Weekly downloads
11
License
MIT
Repository
github
Last release
2 years ago

@fengsi/nuxt-robots

Setup

  1. Add @fengsi/nuxt-robots dependency to your project
yarn add @fengsi/nuxt-robots # or npm install @fengsi/nuxt-robots
  1. Add @fengsi/nuxt-robots to the modules section of nuxt.config.js
export default {
  modules: [
    // Simple usage
    '@fengsi/nuxt-robots',

    // With options
    ['@fengsi/nuxt-robots', { 
      /* module options */
      cacheTime: 1000 * 60 * 10,
      robots: () => {
        return []
      }
    }]
  ]
}

Using top level options

export default {
  modules: [
    '@fengsi/nuxt-robots'
  ],
  robots: {
    /* module options */
    cacheTime: 1000 * 60 * 10,
    robots: () => {
      return []
    }
  }
}

cache time

default 1000 60 10 s

Options

The module option parameter can be:

Object

export default {
  robots: {
    cacheTime: 1000 * 60 * 10,
    robots: {
      UserAgent: '*',
      Disallow: '/'
    }
  }
}

Array

export default {
  robots: {
    cacheTime: 1000 * 60 * 10,
    robots: [
      {
        UserAgent: 'Googlebot',
        Disallow: () => '/users' // accepts function
      }
    ]
  }
}

Function

export default {
  robots: {
    cacheTime: 1000 * 60 * 10,
    robots: () => {
      return {
        UserAgent: '*',
        Disallow: '/'
      }
    }
  }
}

null

status code: 404

export default {
  robots: {
    cacheTime: 1000 * 60 * 10,
    robots: null
  }
}

Will generate a /robots.txt

User-agent: Googlebot
Disallow: /users
User-agent: Bingbot
Disallow: /admin

The keys and values available:

  • UserAgent = User-agent
  • CrawlDelay = Crawl-delay
  • Disallow = Disallow
  • Allow = Allow
  • Host = Host
  • Sitemap = Sitemap
  • CleanParam = Clean-param

Note: Don't worry keys are parsed with case insensitive and special characters.

The original link @nuxtjs/robots

1.0.2

2 years ago

1.0.1

3 years ago

1.0.0

3 years ago