@@ -4,6 +4,27 @@ const fetch = require('node-fetch');
4
4
5
5
const VERSIONS_JSON = require ( './versions.json' ) ;
6
6
7
+ /**
8
+ * Old versions of the Ionic Docs are archived so
9
+ * that we do not need to re-build it every time we deploy.
10
+ * Building a large number of docs sites at once can cause
11
+ * out of memory issues, so archiving old docs sites
12
+ * allow us to keep memory usage and build times low.
13
+ *
14
+ * Note that this file is only for versions of the Ionic Docs
15
+ * that are built with Docusaurus. The
16
+ * Ionic v3 and v4 docs are built with other tools, so those
17
+ * versions are not included here.
18
+ */
19
+ const ARCHIVED_VERSIONS_JSON = require ( './versionsArchived.json' ) ;
20
+
21
+ /**
22
+ * This returns an array where each entry is an array
23
+ * containing the version name at index 0 and
24
+ * the archive url at index 1.
25
+ */
26
+ const ArchivedVersionsDropdownItems = Object . entries ( ARCHIVED_VERSIONS_JSON ) . splice ( 0 , 5 ) ;
27
+
7
28
const BASE_URL = '/docs' ;
8
29
9
30
module . exports = {
@@ -165,6 +186,20 @@ module.exports = {
165
186
type : 'docsVersionDropdown' ,
166
187
position : 'right' ,
167
188
dropdownItemsAfter : [
189
+ ...ArchivedVersionsDropdownItems . map ( ( [ versionName , versionUrl ] ) => ( {
190
+ label : versionName ,
191
+ /**
192
+ * Use "to" instead of "href" so the
193
+ * external URL icon does not show up.
194
+ */
195
+ to : versionUrl ,
196
+ /**
197
+ * Just like the version docs in this project,
198
+ * we want to archived versions to open in the
199
+ * same tab.
200
+ */
201
+ target : '_self' ,
202
+ } ) ) ,
168
203
{ to : 'https://ionicframework.com/docs/v4/components' , label : 'v4' , target : '_blank' } ,
169
204
{ to : 'https://ionicframework.com/docs/v3/' , label : 'v3' , target : '_blank' } ,
170
205
] ,
0 commit comments