1.0.2 • Published 4 years ago
@fengsi/nuxt-robots v1.0.2
@fengsi/nuxt-robots
Setup
- Add
@fengsi/nuxt-robotsdependency to your project
yarn add @fengsi/nuxt-robots # or npm install @fengsi/nuxt-robots- Add
@fengsi/nuxt-robotsto themodulessection ofnuxt.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: /adminThe 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