Skip to content

Commit 863dbca

Browse files
B4nanclaude
andauthored
docs: port docs fixes from apify-docs (#3544)
## Summary - Gracefully skip code signing in roa-loader when `APIFY_SIGNING_TOKEN` is not set — logs a one-time warning instead of hitting the API and failing - Patch `@signalwire/docusaurus-plugin-llms-txt` to emit proper mdast `break` nodes instead of raw `<br />` HTML in `.md` export Ported from apify/apify-docs#2207 and apify/apify-docs#2239. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9586a6a commit 863dbca

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/node_modules/@signalwire/docusaurus-plugin-llms-txt/lib/transformation/plugins/plugin-registry.js b/node_modules/@signalwire/docusaurus-plugin-llms-txt/lib/transformation/plugins/plugin-registry.js
2+
index f35c2df..4d8b9bd 100644
3+
--- a/node_modules/@signalwire/docusaurus-plugin-llms-txt/lib/transformation/plugins/plugin-registry.js
4+
+++ b/node_modules/@signalwire/docusaurus-plugin-llms-txt/lib/transformation/plugins/plugin-registry.js
5+
@@ -73,7 +73,7 @@ export class PluginRegistry {
6+
}
7+
// Always last - converts HTML AST to Markdown AST
8+
processor.use(rehypeRemark, {
9+
- handlers: { br: () => ({ type: 'html', value: '<br />' }) },
10+
+ handlers: { br: () => ({ type: 'break' }) },
11+
});
12+
}
13+
/**

website/roa-loader/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ const { inspect } = require('node:util');
33

44
const { urlToRequest } = require('loader-utils');
55

6+
const SIGNING_TOKEN = process.env.APIFY_SIGNING_TOKEN;
67
const signingUrl = new URL('https://api.apify.com/v2/tools/encode-and-sign');
7-
signingUrl.searchParams.set('token', process.env.APIFY_SIGNING_TOKEN);
8+
signingUrl.searchParams.set('token', SIGNING_TOKEN || '');
89
const queue = [];
910
const cache = {};
1011
let working = false;
12+
let warnedAboutMissingToken = false;
1113

1214
function hash(source) {
1315
return createHash('sha1').update(source).digest('hex');
@@ -89,6 +91,15 @@ module.exports = async function (code) {
8991
return { code, hash: 'fast' };
9092
}
9193

94+
// Skip signing if token is not configured
95+
if (!SIGNING_TOKEN) {
96+
if (!warnedAboutMissingToken) {
97+
console.warn('APIFY_SIGNING_TOKEN is not set, skipping code signing for runnable examples.');
98+
warnedAboutMissingToken = true;
99+
}
100+
return { code, hash: 'unsigned' };
101+
}
102+
92103
console.log(`Signing ${urlToRequest(this.resourcePath)}...`, { working, queue: queue.length });
93104
const codeHash = await encodeAndSign(code);
94105
return { code, hash: codeHash };

website/src/theme/DocItem/Content/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import BrowserOnly from '@docusaurus/BrowserOnly';
12
import { useDoc } from '@docusaurus/plugin-content-docs/client';
23
import { ThemeClassNames } from '@docusaurus/theme-common';
34
import LLMButtons from '@site/src/components/LLMButtons';
@@ -27,7 +28,7 @@ export default function DocItemContent({ children }) {
2728
{syntheticTitle && (
2829
<div className={styles.docItemContent}>
2930
{syntheticTitle && <Heading as="h1">{syntheticTitle}</Heading>}
30-
<LLMButtons />
31+
<BrowserOnly>{() => <LLMButtons />}</BrowserOnly>
3132
</div>
3233
)}
3334
<MDXContent>{children}</MDXContent>

0 commit comments

Comments
 (0)