Skip to content

Commit 0d06eb3

Browse files
Automatically wrap the definition component on relevant terms (#1323)
This PR adds a custom rehype plugin that wraps the first instance of certain technical terms in a `<Definition>` component automatically. Here's how it looks: https://github.com/user-attachments/assets/a55e39cf-f424-422b-92fb-2fa31001c732 [Preview here](https://ngrok-docs-git-shaquil-doc-267-automatically-w-1615c7-ngrok-dev.vercel.app/docs/k8s/installation/install/) Because this plugin adds the component automatically, we get this functionality for free everywhere in the docs. This opens up a lot of possibilities: 1. We can add as many technical terms as we think users may be confused by, and since the component is a popover they can learn the meanings without leaving the page. 2. We could potentially add our own product terminology to the list of terms. For example, if we add "Traffic Policy" and link to that docs page, then the first instance of Traffic Policy on every page of the docs will automatically be linked. The same goes for our other terms 3. We can define proprietary terms like "ngrok's cloud service" without having a full dedicated docs page ## How to test Mostly, click around the site and see if the terms listed are highlighted on the pages they appear on. Terms include: - IP CIDR - CEL - Gateway API CDR - CDR - SCIM - JIT Provisioning - K8s - Ingress - TCP Keepalive - v3 - v2 - OWASP - Helm - TLS Termination - ALPN - SNI ## Considerations - I've noticed no apparent slowdown in page loads either in localhost or in the preview deployment as a result of this plugin - Vercel build times appear to be slower by 1 minute due to this plugin (from 7.5 minutes to 8.5 minutes). Local build times appear to be slower by about 1 minute as well. - For localhost, this is only relevant to the initial build of the site when running `pnpm run dev`. HMR is not slower. ## Other changes This also updates our codeblock component to more accurately align with the redesign by Micah - [Check it out here](https://ngrok.slack.com/archives/C062MGJHNV6/p1743797304496219?thread_ts=1743788702.760899&cid=C062MGJHNV6) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 9bae70f commit 0d06eb3

File tree

21 files changed

+653
-83
lines changed

21 files changed

+653
-83
lines changed

docs/agent-sdks/index.mdx

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,62 @@ ngrok's cloud service just as if you opened a socket to listen on a port.
2323

2424
## Example Usage
2525

26-
<Tabs groupId="connectivity" queryString="cty">
27-
<TabItem value="go-sdk" label="Go SDK">
28-
<RandomGoSdkExample />
29-
</TabItem>
30-
<TabItem value="javascript-sdk" label="Javascript SDK">
31-
<RandomJavascriptSdkExample />
32-
</TabItem>
33-
<TabItem value="python-sdk" label="Python SDK">
34-
<RandomPythonSdkExample />
35-
</TabItem>
36-
<TabItem value="rust-sdk" label="Rust SDK">
37-
<RandomRustSdkExample />
38-
</TabItem>
39-
</Tabs>
26+
<LangSwitcher>
27+
```go
28+
import (
29+
"context"
30+
"net"
31+
"golang.ngrok.com/ngrok/v2"
32+
)
33+
34+
func ngrokListener(ctx context.Context) (net.Listener, error) {
35+
return ngrok.Listen(ctx)
36+
}
37+
38+
````
39+
40+
```javascript
41+
const ngrok = require("@ngrok/ngrok");
42+
43+
(async function () {
44+
const listener = await ngrok.forward({
45+
addr: 8080,
46+
authtoken_from_env: true,
47+
});
48+
49+
console.log(`Ingress established at: ${listener.url()}`);
50+
})();
51+
````
52+
53+
```python
54+
import ngrok
55+
56+
listener = ngrok.forward("localhost:8080", authtoken_from_env=True)
57+
58+
print(f"Ingress established at: {listener.url()}");
59+
```
60+
61+
```rust
62+
use ngrok::prelude::*;
63+
64+
async fn listen_ngrok() -> anyhow::Result<impl Tunnel> {
65+
let sess = ngrok::Session::builder()
66+
.authtoken_from_env()
67+
.connect()
68+
.await?;
69+
70+
let tun = sess
71+
.http_endpoint()
72+
.listen()
73+
.await?;
74+
75+
println!("Listening on URL: {:?}", tun.url());
76+
77+
Ok(tun)
78+
}
79+
```
80+
81+
</LangSwitcher>
4082

4183
## Supported Languages
4284

docs/iam/users.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { Definition } from "/src/components/Definition/";
2-
31
# Users
42

53
Users are members of your Account that may log into the dashboard, start
@@ -50,7 +48,7 @@ additional details on configuring it.
5048

5149
In addition to the normal authentication factors required to log into the ngrok
5250
dashboard, you may also configure your ngrok account to further restrict
53-
dashboard access to a set of <Definition>IP CIDR</Definition> blocks.
51+
dashboard access to a set of IP CIDR blocks.
5452

5553
Dashboard IP Restrictions should always be used in a warning mode first to test
5654
that you won't accidentally lock yourself out of your account if you restrict
@@ -107,7 +105,7 @@ Settings page](https://dashboard.ngrok.com/settings). By default, you provision
107105
new users by inviting them to join your Account with Invitations.
108106

109107
If you have configured [SSO](#single-sign-on), you may also add users to your
110-
account via the <Definition>SCIM</Definition> or <Definition>JIT provisioning</Definition> methods.
108+
account via the SCIM or JIT provisioning methods.
111109

112110
### Invitations
113111

docs/whats-new.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ You can expect this page to update regularly (at least monthly). We'll include t
1414

1515
## March 2025
1616

17-
- 2025-03-13 - Agent now supports TCP KeepAlive configuration.
17+
- 2025-03-13 - Agent now supports TCP-KeepAlive configuration.
1818

1919
## February 2025
2020

docusaurus.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ const config = {
133133
docs: {
134134
sidebarPath: require.resolve("./sidebars.js"),
135135
routeBasePath: "/",
136+
rehypePlugins: [require("./src/plugins/definition-wrapper")],
136137
editUrl: `${docsRepo}/edit/main`,
137138
showLastUpdateAuthor: true,
138139
showLastUpdateTime: true,

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
"@ngrok/mantle": "0.27.2",
4545
"@phosphor-icons/react": "2.1.7",
4646
"@stackql/docusaurus-plugin-hubspot": "1.1.0",
47+
"@types/capitalize": "^2.0.2",
4748
"algoliasearch": "5.24.0",
49+
"capitalize": "^2.0.4",
4850
"clsx": "2.1.1",
4951
"concurrently": "9.1.2",
5052
"cross-env": "7.0.3",
@@ -56,6 +58,7 @@
5658
"react-hubspot-form": "1.3.7",
5759
"react-markdown": "10.1.0",
5860
"react-player": "2.16.0",
61+
"unist-util-visit": "^5.0.0",
5962
"yaml": "2.7.1",
6063
"zod": "3.24.4"
6164
},

pnpm-lock.yaml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/CodeBlockWithInfo/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,30 +50,30 @@ export function CodeBlockWithInfo({
5050
<div className="flex flex-col">
5151
<CodeBlock className={className} {...codeBlockProps}>
5252
<CodeBlockHeader className={clsx("flex w-[100%] justify-start p-2")}>
53-
{headerContent}
54-
{info && <SdkButton className="ml-auto mr-0.5" data={info} />}
55-
</CodeBlockHeader>
56-
<CodeBlockBody>
5753
{meta?.title && (
58-
<div className="mx-2 mt-3.5 flex w-[100%] items-end justify-start gap-1">
54+
<div className="flex w-[100%] items-end justify-start gap-1">
5955
<>
6056
{meta?.mode ? (
6157
<CodeBlockIcon preset={meta.mode} />
6258
) : (
6359
<CodeBlockIcon preset="file" />
6460
)}
65-
<CodeBlockTitle>
61+
<CodeBlockTitle className="font-sans">
6662
{meta?.titleLink ? (
6763
<a href={useBaseUrl(meta.titleLink)}>
6864
<strong>{meta.title}</strong>
6965
</a>
7066
) : (
71-
<strong>{meta?.title}</strong>
67+
<strong>{meta.title}</strong>
7268
)}
7369
</CodeBlockTitle>
7470
</>
7571
</div>
7672
)}
73+
<span className="justify-end mr-0.5 ml-auto">{headerContent}</span>
74+
{info && <SdkButton className="ml-4 mr-0.5" data={info} />}
75+
</CodeBlockHeader>
76+
<CodeBlockBody>
7777
{!meta?.disableCopy && <CodeBlockCopyButton />}
7878
<CodeBlockCode
7979
indentation={meta?.indentation}

src/components/ConfigExample.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const showExample = (
1919
) => {
2020
const titleToUse = title || defaultTitle;
2121
return (
22-
<LangSwitcher>
22+
<LangSwitcher className="mb-3">
2323
<DocsCodeBlock
2424
language="yaml"
2525
metastring={yamlMetastring}

0 commit comments

Comments
 (0)