The Node.js® Website
at main 5.8 kB view raw
1'use strict'; 2 3/** 4 * This is used to verify if the current Website is running on a Development Environment 5 */ 6export const IS_DEVELOPMENT = process.env.NODE_ENV === 'development'; 7 8/** 9 * This is used for telling Next.js if the Website is deployed on Vercel 10 * 11 * Can be used for conditionally enabling features that we know are Vercel only 12 * 13 * @see https://vercel.com/docs/concepts/projects/environment-variables/system-environment-variables#framework-environment-variables 14 */ 15export const VERCEL_ENV = process.env.NEXT_PUBLIC_VERCEL_ENV || undefined; 16 17/** 18 * This is used for defining a default time of when `next-data` and other dynamically generated 19 * but static-enabled pages should be regenerated. 20 * 21 * Note that this is a custom Environment Variable that can be defined by us when necessary 22 */ 23export const VERCEL_REVALIDATE = Number( 24 process.env.NEXT_PUBLIC_VERCEL_REVALIDATE_TIME || 300 25); 26 27/** 28 * This is used for telling Next.js to to a Static Export Build of the Website 29 * 30 * This is used for static/without a Node.js server hosting, such as on our 31 * legacy Website Build Environment on Node.js's DigitalOcean Droplet. 32 * 33 * Note that this is a manual Environment Variable defined by us during `npm run deploy` 34 */ 35export const ENABLE_STATIC_EXPORT = 36 process.env.NEXT_PUBLIC_STATIC_EXPORT === 'true' || 37 process.env.NEXT_PUBLIC_STATIC_EXPORT === true; 38 39/** 40 * This is used for any place that requires the full canonical URL path for the Node.js Website (and its deployment), such as for example, the Node.js RSS Feed. 41 * 42 * This variable can either come from the Vercel Deployment as `NEXT_PUBLIC_VERCEL_URL` or from the `NEXT_PUBLIC_BASE_URL` Environment Variable that is manually defined 43 * by us if necessary. Otherwise it will fallback to the default Node.js Website URL. 44 * 45 * @see https://vercel.com/docs/concepts/projects/environment-variables/system-environment-variables#framework-environment-variables 46 */ 47export const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL 48 ? process.env.NEXT_PUBLIC_BASE_URL 49 : process.env.NEXT_PUBLIC_VERCEL_URL 50 ? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}` 51 : 'https://nodejs.org'; 52 53/** 54 * This is used for any place that requires the Node.js distribution URL (which by default is nodejs.org/dist) 55 * 56 * Note that this is a custom Environment Variable that can be defined by us when necessary 57 */ 58export const DIST_URL = 59 process.env.NEXT_PUBLIC_DIST_URL || 'https://nodejs.org/dist/'; 60 61/** 62 * This is used for any place that requires the Node.js API Docs URL (which by default is nodejs.org/docs) 63 * 64 * Note that this is a custom Environment Variable that can be defined by us when necessary 65 */ 66export const DOCS_URL = 67 process.env.NEXT_PUBLIC_DOCS_URL || 'https://nodejs.org/docs/'; 68 69/** 70 * Supports a manual override of the base path of the Website 71 * 72 * This is useful when running the deployment on a subdirectory 73 * of a domain, such as when hosted on GitHub Pages. 74 * 75 * Note that this is a custom Environment Variable that can be defined by us when necessary 76 */ 77export const BASE_PATH = process.env.NEXT_PUBLIC_BASE_PATH || ''; 78 79/** 80 * This is used for fetching static next-data through the /en/next-data/ endpoint 81 * 82 * Note this is assumes that the Node.js Website is either running within Vercel Environment 83 * or running locally (either production or development) mode 84 * 85 * Note this variable can be overridden via a manual Environment Variable defined by us if necessary. 86 */ 87export const NEXT_DATA_URL = process.env.NEXT_PUBLIC_DATA_URL 88 ? process.env.NEXT_PUBLIC_DATA_URL 89 : VERCEL_ENV 90 ? `${BASE_URL}${BASE_PATH}/en/next-data/` 91 : `http://localhost:3000/en/next-data/`; 92 93/** 94 * This ReGeX is used to remove the `index.md(x)` suffix of a name and to remove 95 * the `.md(x)` extensions of a filename. 96 * 97 * This RegEx is used to transform the file system pathnames into acceptable 98 * Route Segments for Next.js Dynamic Routes on `pages/[...path].tsx` 99 */ 100export const MD_EXTENSION_REGEX = /((\/)?(index))?\.mdx?$/i; 101 102/** 103 * This defines how many blog posts each pagination page should have 104 */ 105export const BLOG_POSTS_PER_PAGE = 6; 106 107/** 108 * The `localStorage` key to store the theme choice of `next-themes` 109 * 110 * This is what allows us to store user preference for theming 111 */ 112export const THEME_STORAGE_KEY = 'theme'; 113 114/** 115 * This is a list of all external links that are used on website sitemap. 116 * @see https://github.com/nodejs/nodejs.org/issues/5813 for more context 117 */ 118export const EXTERNAL_LINKS_SITEMAP = [ 119 'https://terms-of-use.openjsf.org/', 120 'https://privacy-policy.openjsf.org/', 121 'https://bylaws.openjsf.org/', 122 'https://code-of-conduct.openjsf.org/', 123 'https://trademark-policy.openjsf.org/', 124 'https://trademark-list.openjsf.org/', 125 'https://www.linuxfoundation.org/cookies', 126]; 127 128/** 129 * These are the default Orama Query Parameters that are used by the Website 130 * @see https://docs.oramasearch.com/open-source/usage/search/introduction 131 */ 132export const DEFAULT_ORAMA_QUERY_PARAMS = { 133 mode: 'fulltext', 134 limit: 8, 135 threshold: 0, 136 boost: { 137 pageSectionTitle: 4, 138 pageSectionContent: 2.5, 139 pageTitle: 1.5, 140 }, 141 facets: { 142 siteSection: {}, 143 }, 144}; 145 146/** 147 * The default batch size to use when syncing Orama Cloud 148 */ 149export const ORAMA_SYNC_BATCH_SIZE = 50; 150 151/** 152 * The default Orama Cloud endpoint to use when searching with Orama Cloud. 153 */ 154export const ORAMA_CLOUD_ENDPOINT = 155 process.env.NEXT_PUBLIC_ORAMA_ENDPOINT || 156 'https://cloud.orama.run/v1/indexes/nodejs-org-dev-hhqrzv'; 157 158/** 159 * The default Orama Cloud API Key to use when searching with Orama Cloud. 160 * This is a public API key and can be shared publicly on the frontend. 161 */ 162export const ORAMA_CLOUD_API_KEY = process.env.NEXT_PUBLIC_ORAMA_API_KEY || '';