diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 10594a75cb4a8..374b3f715492a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -128,7 +128,7 @@ Our documentation is organized in the [`docs/`](./docs/) directory, so check out ## Project Maintainers -This project is maintained by the [Node.js Website Team](https://github.com/nodejs/nodejs.org#readme). For questions about governance or high-level project direction, you can: +This project is maintained by the [Node.js Website Team](https://github.com/nodejs/web-team/blob/main/MEMBERS.md#nodejs-website-team-nodejsnodejs-website). For questions about governance or high-level project direction, you can: - Mention `@nodejs/nodejs-website` in issues or PRs - Contact team members directly for guidance diff --git a/apps/site/components/Common/LinkTabs.tsx b/apps/site/components/Common/LinkTabs.tsx index 60c9c4d716668..f27904eaed6db 100644 --- a/apps/site/components/Common/LinkTabs.tsx +++ b/apps/site/components/Common/LinkTabs.tsx @@ -1,15 +1,11 @@ -'use client'; - import BaseLinkTabs from '@node-core/ui-components/Common/BaseLinkTabs'; import type { LinkTabsProps } from '@node-core/ui-components/Common/BaseLinkTabs'; import type { FC } from 'react'; import Link from '#site/components/Link'; -import { useRouter } from '#site/navigation.mjs'; -const LinkTabs: FC> = props => { - const { push } = useRouter(); - return push(value)} as={Link} {...props} />; +const LinkTabs: FC> = props => { + return ; }; export default LinkTabs; diff --git a/apps/site/components/Common/Supporters/index.tsx b/apps/site/components/Common/Supporters/index.tsx index 67f985b91c466..63e01509efe63 100644 --- a/apps/site/components/Common/Supporters/index.tsx +++ b/apps/site/components/Common/Supporters/index.tsx @@ -1,5 +1,3 @@ -'use client'; - import Avatar from '@node-core/ui-components/Common/AvatarGroup/Avatar'; import type { FC } from 'react'; diff --git a/apps/site/components/Downloads/DownloadButton/index.tsx b/apps/site/components/Downloads/DownloadButton/index.tsx index 54d77889e85bc..c280f2d8f83ac 100644 --- a/apps/site/components/Downloads/DownloadButton/index.tsx +++ b/apps/site/components/Downloads/DownloadButton/index.tsx @@ -1,11 +1,9 @@ -'use client'; - import { CloudArrowDownIcon } from '@heroicons/react/24/outline'; import classNames from 'classnames'; import type { FC, PropsWithChildren } from 'react'; +import { getClientContext } from '#site/client-context'; import Button from '#site/components/Common/Button'; -import { useClientContext } from '#site/hooks'; import type { NodeRelease } from '#site/types'; import { getNodeDownloadUrl } from '#site/util/url'; import { getUserPlatform } from '#site/util/userAgent'; @@ -18,7 +16,7 @@ const DownloadButton: FC> = ({ release: { versionWithPrefix }, children, }) => { - const { os, bitness, architecture } = useClientContext(); + const { os, bitness, architecture } = getClientContext(); const platform = getUserPlatform(architecture, bitness); const downloadLink = getNodeDownloadUrl({ versionWithPrefix, os, platform }); diff --git a/apps/site/components/Downloads/DownloadLink.tsx b/apps/site/components/Downloads/DownloadLink.tsx index 9dced0f04e026..c5887935d0ff4 100644 --- a/apps/site/components/Downloads/DownloadLink.tsx +++ b/apps/site/components/Downloads/DownloadLink.tsx @@ -1,9 +1,7 @@ -'use client'; - import type { FC, PropsWithChildren } from 'react'; +import { getClientContext } from '#site/client-context'; import LinkWithArrow from '#site/components/Common/LinkWithArrow'; -import { useClientContext } from '#site/hooks'; import type { DownloadKind, NodeRelease } from '#site/types'; import { getNodeDownloadUrl } from '#site/util/url'; import { getUserPlatform } from '#site/util/userAgent'; @@ -15,7 +13,7 @@ const DownloadLink: FC> = ({ kind = 'installer', children, }) => { - const { os, bitness, architecture } = useClientContext(); + const { os, bitness, architecture } = getClientContext(); const platform = getUserPlatform(architecture, bitness); diff --git a/apps/site/pages/en/learn/command-line/how-to-read-environment-variables-from-nodejs.md b/apps/site/pages/en/learn/command-line/how-to-read-environment-variables-from-nodejs.md index 12bd03360d9ca..9afb46f342ba1 100644 --- a/apps/site/pages/en/learn/command-line/how-to-read-environment-variables-from-nodejs.md +++ b/apps/site/pages/en/learn/command-line/how-to-read-environment-variables-from-nodejs.md @@ -1,7 +1,7 @@ --- title: How to read environment variables from Node.js layout: learn -authors: flaviocopes, MylesBorins, fhemberger, LaRuaNa, ahmadawais, manishprivet, nikhilbhatt +authors: flaviocopes, MylesBorins, fhemberger, LaRuaNa, ahmadawais, manishprivet, nikhilbhatt, ycmjason --- # How to read environment variables from Node.js @@ -64,3 +64,34 @@ throwing an error if the file is missing using the `--env-file-if-exists` flag. ```bash node --env-file-if-exists=.env app.js ``` + +## Loading `.env` files programmatically with `process.loadEnvFile(path)` + +Node.js provides a built-in API to load `.env` files directly from your code: [`process.loadEnvFile(path)`](https://nodejs.org/api/process.html#processloadenvfilepath). + +This method loads variables from a `.env` file into `process.env`, similar to how the `--env-file` flag works — but can be invoked programmatically. + +Because this method is invoked post-initialization, the setting of startup-related environment variables (i.e. `NODE_OPTIONS`) has no effect on the process (however, these variables can still be accessed via `process.env`). + +### Example + +```txt +// .env file +PORT=1234 +``` + +```js +const { loadEnvFile } = require('node:process'); + +// Loads environment variables from the default .env file +loadEnvFile(); + +console.log(process.env.PORT); // Logs '1234' +``` + +You can also specify a custom path: + +```js +const { loadEnvFile } = require('node:process'); +loadEnvFile('./config/.env'); +``` diff --git a/packages/ui-components/src/Common/BaseLinkTabs/index.module.css b/packages/ui-components/src/Common/BaseLinkTabs/index.module.css index b8375d692a6c6..1163801c4fd52 100644 --- a/packages/ui-components/src/Common/BaseLinkTabs/index.module.css +++ b/packages/ui-components/src/Common/BaseLinkTabs/index.module.css @@ -38,13 +38,5 @@ } .tabsSelect { - @apply sm:visible - md:hidden; - - > span { - @apply max-xs:flex - my-6 - hidden - w-full; - } + @apply md:hidden; } diff --git a/packages/ui-components/src/Common/BaseLinkTabs/index.tsx b/packages/ui-components/src/Common/BaseLinkTabs/index.tsx index 81ec353f178c7..fd39e5fd8a234 100644 --- a/packages/ui-components/src/Common/BaseLinkTabs/index.tsx +++ b/packages/ui-components/src/Common/BaseLinkTabs/index.tsx @@ -1,9 +1,9 @@ import type { FC, PropsWithChildren } from 'react'; -import Select from '#ui/Common/Select'; import type { LinkLike } from '#ui/types'; import styles from './index.module.css'; +import StatelessSelect from '../Select/StatelessSelect'; type LinkTab = { key: string; label: string; link: string }; @@ -12,7 +12,6 @@ export type LinkTabsProps = PropsWithChildren<{ tabs: Array; activeTab: string; as?: LinkLike; - onSelect: (value: string) => void; }>; const BaseLinkTabs: FC = ({ @@ -21,7 +20,6 @@ const BaseLinkTabs: FC = ({ activeTab, children, as: Component = 'a', - onSelect, }) => ( <>
@@ -37,14 +35,12 @@ const BaseLinkTabs: FC = ({ ))}
-
-