diff --git a/docs/nuxt.config.js b/docs/nuxt.config.js index e2cf4b73409..694c733559b 100644 --- a/docs/nuxt.config.js +++ b/docs/nuxt.config.js @@ -21,6 +21,13 @@ const RX_CODE_FILENAME = /^\/\/ ([\w,\s-]+\.[A-Za-z]{1,4})\n/m const ANCHOR_LINK_HEADING_LEVELS = [2, 3, 4, 5] +// Determine if documentation generation is published production docs +// Must be from 'bootstrap-vue/bootstrap-vue' repo 'master' branch +const IS_PROD_DOCS = + process.env.VERCEL_GITHUB_ORG === 'bootstrap-vue' && + process.env.VERCEL_GITHUB_REPO === 'bootstrap-vue' && + process.env.VERCEL_GITHUB_COMMIT_REF === 'master' + // --- Utility methods --- // Get routes by a given dir @@ -154,17 +161,17 @@ module.exports = { // ENV vars provided by Vercel/Zeit Now build // https://zeit.co/docs/v2/build-step#system-environment-variables // - `true` if on Zeit Now (dev or PR) - VERCEL_NOW: process.env.VERCEL_GITHUB_DEPLOYMENT || process.env.NOW_GITHUB_DEPLOYMENT, + VERCEL_NOW: process.env.VERCEL_GITHUB_DEPLOYMENT, // - The branch name used for the deploy (i.e. `dev`, `master`, `patch-1`, etc) - VERCEL_BRANCH: process.env.VERCEL_GITHUB_COMMIT_REF || process.env.NOW_GITHUB_COMMIT_REF, + VERCEL_BRANCH: process.env.VERCEL_GITHUB_COMMIT_REF, // - The Commit SHA hash - VERCEL_COMMIT_SHA: process.env.VERCEL_GITHUB_COMMIT_SHA || process.env.NOW_GITHUB_COMMIT_SHA, + VERCEL_COMMIT_SHA: process.env.VERCEL_GITHUB_COMMIT_SHA, // - The deployment URL - VERCEL_URL: process.env.VERCEL_URL || process.env.NOW_URL, + VERCEL_URL: process.env.VERCEL_URL, // - The Github Organization (ie. bootstrap-vue) - VERCEL_GITHUB_ORG: process.env.VERCEL_GITHUB_ORG || process.env.NOW_GITHUB_ORG, + VERCEL_GITHUB_ORG: process.env.VERCEL_GITHUB_ORG, // - The repo is the organization (i.e. bootstrap-vue) - VERCEL_GITHUB_REPO: process.env.VERCEL_GITHUB_REPO || process.env.NOW_GITHUB_REPO + VERCEL_GITHUB_REPO: process.env.VERCEL_GITHUB_REPO }, build: { @@ -269,7 +276,7 @@ module.exports = { plugins: ['~/plugins/bootstrap-vue.js', '~/plugins/play.js', '~/plugins/docs.js'], buildModules: ['@nuxtjs/google-analytics'], - modules: ['@nuxtjs/pwa'], + modules: ['@nuxtjs/pwa', '@nuxtjs/robots', '@nuxtjs/sitemap'], 'google-analytics': { id: GA_TRACKING_ID, @@ -278,6 +285,25 @@ module.exports = { } }, + // We enable crawling in production docs only + robots: () => { + // In production docs we allow crawling, else we deny crawling + return [IS_PROD_DOCS ? { UserAgent: '*', Allow: '/' } : { UserAgent: '*', Disallow: '/' }] + }, + + // We only include a populated `sitemap.xml` in production docs + sitemap: { + // Sitemaps requires a hostname, so we use localhost in + // non-prod mode just to make the sitemap module happy + hostname: IS_PROD_DOCS ? BASE_URL : 'http://localhost', + // Exclude all static routes when not prod + // Exclude only redirect routes in prod + exclude: IS_PROD_DOCS ? ['/docs/misc', '/docs/misc/**', '/docs/layout'] : ['/', '/**'], + // Include dynamic slug routes (from `generate.routes`) in prod, while + // in non-prod docs we do not include dynamic routes (empty array) + ...(IS_PROD_DOCS ? {} : { routes: [] }) + }, + head: { meta: [{ 'http-equiv': 'X-UA-Compatible', content: 'IE=edge' }], script: [ diff --git a/package.json b/package.json index 179b0c15b8c..eefb25d23d1 100644 --- a/package.json +++ b/package.json @@ -105,6 +105,8 @@ "@babel/standalone": "^7.9.5", "@nuxtjs/google-analytics": "^2.2.3", "@nuxtjs/pwa": "^3.0.0-beta.20", + "@nuxtjs/robots": "^2.4.2", + "@nuxtjs/sitemap": "^2.2.1", "@vue/test-utils": "1.0.0-beta.29", "autoprefixer": "^9.7.6", "babel-core": "^7.0.0-bridge.0", diff --git a/yarn.lock b/yarn.lock index 64813e1382e..39982518e35 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1518,6 +1518,26 @@ jimp-compact "^0.8.0" workbox-cdn "^4.3.1" +"@nuxtjs/robots@^2.4.2": + version "2.4.2" + resolved "https://registry.yarnpkg.com/@nuxtjs/robots/-/robots-2.4.2.tgz#9a96c91abb70e39b414eec502ef1cf7d5ef0235e" + integrity sha512-BW3qhvxlPBKlMkZHtARFPeliFraiZHS28G3j4qgRbSfOBtHC0yDX3Dnq1LkQMzAbPfbw6A1L3sdjgBVZZnfFAw== + +"@nuxtjs/sitemap@^2.2.1": + version "2.2.1" + resolved "https://registry.yarnpkg.com/@nuxtjs/sitemap/-/sitemap-2.2.1.tgz#a00b528e361673b3f2651a0f1ee4081e89f9c6fd" + integrity sha512-GrXTueBaSQgAuBbUrGcKu37VbZBOZ4omHqk8FfthK71R26vp9LWUcqlRbuQaIrAYynjSfSPxaLpX8opUwO1nKw== + dependencies: + async-cache "^1.1.0" + consola "^2.11.3" + etag "^1.8.1" + fresh "^0.5.2" + fs-extra "^8.1.0" + is-https "^1.0.0" + lodash.unionby "^4.8.0" + minimatch "^3.0.4" + sitemap "^4.1.1" + "@nuxtjs/youch@^4.2.3": version "4.2.3" resolved "https://registry.yarnpkg.com/@nuxtjs/youch/-/youch-4.2.3.tgz#36f8b22df5a0efaa81373109851e1d857aca6bed" @@ -1633,6 +1653,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-13.11.0.tgz#390ea202539c61c8fa6ba4428b57e05bc36dc47b" integrity sha512-uM4mnmsIIPK/yeO+42F2RQhGUIs39K2RFmugcJANppXe6J1nvH87PvzPZYpza7Xhhs8Yn9yIAVdLZ84z61+0xQ== +"@types/node@^12.0.2": + version "12.12.37" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.37.tgz#cb4782d847f801fa58316da5b4801ca3a59ae790" + integrity sha512-4mXKoDptrXAwZErQHrLzpe0FN/0Wmf5JRniSVIdwUrtDf9wnmEV1teCNLBo/TwuXhkK/bVegoEn/wmb+x0AuPg== + "@types/normalize-package-data@^2.4.0": version "2.4.0" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" @@ -1660,6 +1685,13 @@ dependencies: "@types/node" "*" +"@types/sax@^1.2.0": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@types/sax/-/sax-1.2.1.tgz#e0248be936ece791a82db1a57f3fb5f7c87e8172" + integrity sha512-dqYdvN7Sbw8QT/0Ci5rhjE4/iCMJEM0Y9rHpCu+gGXD9Lwbz28t6HI2yegsB6BoV1sShRMU6lAmAcgRjmFy7LA== + dependencies: + "@types/node" "*" + "@types/stack-utils@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e" @@ -2185,6 +2217,11 @@ are-we-there-yet@~1.1.2: delegates "^1.0.0" readable-stream "^2.0.6" +arg@^4.1.1: + version "4.1.3" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== + argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" @@ -2320,6 +2357,13 @@ astral-regex@^1.0.0: resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg== +async-cache@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/async-cache/-/async-cache-1.1.0.tgz#4a9a5a89d065ec5d8e5254bd9ee96ba76c532b5a" + integrity sha1-SppaidBl7F2OUlS9nulrp2xTK1o= + dependencies: + lru-cache "^4.0.0" + async-each@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.3.tgz#b727dbf87d7651602f06f4d4ac387f47d91b0cbf" @@ -6938,6 +6982,11 @@ is-hexadecimal@^1.0.0: resolved "https://registry.yarnpkg.com/is-hexadecimal/-/is-hexadecimal-1.0.4.tgz#cc35c97588da4bd49a8eedd6bc4082d44dcb23a7" integrity sha512-gyPJuv83bHMpocVYoqof5VDiZveEoGoFL8m3BXNb2VW8Xs+rz9kqO8LOQ5DH6EsuvilT1ApazU0pyl+ytbPtlw== +is-https@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-https/-/is-https-1.0.0.tgz#9c1dde000dc7e7288edb983bef379e498e7cb1bf" + integrity sha512-1adLLwZT9XEXjzhQhZxd75uxf0l+xI9uTSFaZeSESjL3E1eXSPpO+u5RcgqtzeZ1KCaNvtEwZSTO2P4U5erVqQ== + is-installed-globally@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/is-installed-globally/-/is-installed-globally-0.1.0.tgz#0dfd98f5a9111716dd535dda6492f67bf3d25a80" @@ -8166,6 +8215,11 @@ lodash.templatesettings@^4.0.0: dependencies: lodash._reinterpolate "^3.0.0" +lodash.unionby@^4.8.0: + version "4.8.0" + resolved "https://registry.yarnpkg.com/lodash.unionby/-/lodash.unionby-4.8.0.tgz#883f098ff78f564a727b7508e09cdd539734bb83" + integrity sha1-iD8Jj/ePVkpye3UI4JzdU5c0u4M= + lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" @@ -8245,7 +8299,7 @@ lowercase-keys@^1.0.0: resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" integrity sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA== -lru-cache@^4.0.1, lru-cache@^4.1.1, lru-cache@^4.1.2, lru-cache@^4.1.5: +lru-cache@^4.0.0, lru-cache@^4.0.1, lru-cache@^4.1.1, lru-cache@^4.1.2, lru-cache@^4.1.5: version "4.1.5" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g== @@ -11295,7 +11349,7 @@ sass-loader@^8.0.2: schema-utils "^2.6.1" semver "^6.3.0" -sax@~1.2.4: +sax@^1.2.4, sax@~1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== @@ -11528,6 +11582,17 @@ sisteransi@^1.0.4: resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg== +sitemap@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/sitemap/-/sitemap-4.1.1.tgz#c9b459c7d797e629c61f56b86586d4f67dbf250b" + integrity sha512-+8yd66IxyIFEMFkFpVoPuoPwBvdiL7Ap/HS5YD7igqO4phkyTPFIprCAE9NMHehAY5ZGN3MkAze4lDrOAX3sVQ== + dependencies: + "@types/node" "^12.0.2" + "@types/sax" "^1.2.0" + arg "^4.1.1" + sax "^1.2.4" + xmlbuilder "^13.0.0" + slash@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44" @@ -13461,6 +13526,11 @@ xml-name-validator@^3.0.0: resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw== +xmlbuilder@^13.0.0: + version "13.0.2" + resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-13.0.2.tgz#02ae33614b6a047d1c32b5389c1fdacb2bce47a7" + integrity sha512-Eux0i2QdDYKbdbA6AM6xE4m6ZTZr4G4xF9kahI2ukSEMCzwce2eX9WlTI5J3s+NU7hpasFsr8hWIONae7LluAQ== + xmlchars@^2.1.1: version "2.2.0" resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb"