diff --git a/docusaurus.config.js b/docusaurus.config.js index 16413a59785..44e25594cae 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -4,6 +4,27 @@ const fetch = require('node-fetch'); const VERSIONS_JSON = require('./versions.json'); +/** + * Old versions of the Ionic Docs are archived so + * that we do not need to re-build it every time we deploy. + * Building a large number of docs sites at once can cause + * out of memory issues, so archiving old docs sites + * allow us to keep memory usage and build times low. + * + * Note that this file is only for versions of the Ionic Docs + * that are built with Docusaurus. The + * Ionic v3 and v4 docs are built with other tools, so those + * versions are not included here. + */ +const ARCHIVED_VERSIONS_JSON = require('./versionsArchived.json'); + +/** + * This returns an array where each entry is an array + * containing the version name at index 0 and + * the archive url at index 1. + */ +const ArchivedVersionsDropdownItems = Object.entries(ARCHIVED_VERSIONS_JSON).splice(0, 5); + const BASE_URL = '/docs'; module.exports = { @@ -165,6 +186,20 @@ module.exports = { type: 'docsVersionDropdown', position: 'right', dropdownItemsAfter: [ + ...ArchivedVersionsDropdownItems.map(([versionName, versionUrl]) => ({ + label: versionName, + /** + * Use "to" instead of "href" so the + * external URL icon does not show up. + */ + to: versionUrl, + /** + * Just like the version docs in this project, + * we want to archived versions to open in the + * same tab. + */ + target: '_self', + })), { to: 'https://ionicframework.com/docs/v4/components', label: 'v4', target: '_blank' }, { to: 'https://ionicframework.com/docs/v3/', label: 'v3', target: '_blank' }, ], diff --git a/package.json b/package.json index d892d2b4142..f2356cf7e74 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ }, "scripts": { "prebuild": "npm run generate-markdown; scripts/i18n.sh; if [ -n \"$CROWDIN_PERSONAL_TOKEN\" ]; then npm run crowdin:sync; fi", - "build": "NODE_OPTIONS=--max_old_space_size=8192 npm run build:${VERCEL_ENV:-preview}", + "build": "npm run build:${VERCEL_ENV:-preview}", "build:preview": "docusaurus build --locale en", "build:production": "docusaurus build", "clear": "docusaurus clear", diff --git a/versions.json b/versions.json index 3c0ca864655..ed163ab5c09 100644 --- a/versions.json +++ b/versions.json @@ -1,5 +1,4 @@ [ "v7", - "v6", - "v5" + "v6" ] diff --git a/versionsArchived.json b/versionsArchived.json new file mode 100644 index 00000000000..7316dab3747 --- /dev/null +++ b/versionsArchived.json @@ -0,0 +1,3 @@ +{ + "v5": "https://ionic-docs-5utg8ms4c-ionic1.vercel.app/docs/v5/" +}