@apify/docs-theme 1.0.233 → 1.0.235

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apify/docs-theme",
3
- "version": "1.0.233",
3
+ "version": "1.0.235",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "files": [
@@ -168,17 +168,21 @@ const onCopyAsMarkdownClick = async ({ setCopyingStatus }) => {
168
168
  try {
169
169
  setCopyingStatus('loading');
170
170
 
171
- // Fetch the markdown content
172
- const response = await fetch(markdownUrl);
173
-
174
- if (!response.ok) {
175
- throw new Error(`Failed to fetch markdown: ${response.status}`);
176
- }
177
-
178
- const markdownContent = await response.text();
171
+ // Safari requires clipboard writes to be created synchronously inside the user gesture.
172
+ // We therefore pass a Promise that resolves to a Blob into ClipboardItem instead of
173
+ // awaiting fetch first — otherwise Safari would reject the clipboard operation.
174
+ const markdownContent = new ClipboardItem({
175
+ 'text/plain': fetch(markdownUrl)
176
+ .then((response) => {
177
+ if (!response.ok) {
178
+ throw new Error(`Failed to fetch markdown: ${response.status}`);
179
+ }
180
+ return response.text();
181
+ })
182
+ .then((content) => new Blob([content], { type: 'text/plain' })),
183
+ });
179
184
 
180
- // Copy to clipboard
181
- await navigator.clipboard.writeText(markdownContent);
185
+ await navigator.clipboard.write([markdownContent]);
182
186
 
183
187
  // Show success feedback
184
188
  setCopyingStatus('copied');
@@ -1,4 +1,5 @@
1
1
  import Head from '@docusaurus/Head';
2
+ import { useAllDocsData } from '@docusaurus/plugin-content-docs/client';
2
3
  import { useLocation } from '@docusaurus/router';
3
4
  // cannot use any of the theme aliases here as it causes a circular dependency :( ideas welcome
4
5
  import Layout from '@docusaurus/theme-classic/lib/theme/Layout/index';
@@ -9,8 +10,14 @@ import React from 'react';
9
10
  export default function LayoutWrapper(props) {
10
11
  const { options: { subNavbar } } = usePluginData('@apify/docs-theme');
11
12
  const baseUrl = useBaseUrl('/');
12
- const currentPath = useLocation().pathname.replace(new RegExp(`^${baseUrl}`), '').trim();
13
- const shouldRenderAlternateLink = currentPath && currentPath !== '404';
13
+ const { pathname } = useLocation();
14
+ const currentPath = pathname.replace(new RegExp(`^${baseUrl}`), '').trim();
15
+ const allDocsData = useAllDocsData();
16
+ const isVersionedPage = Object.values(allDocsData).some(
17
+ (pluginData) => pluginData.versions.some((version) => !version.isLast && pathname.startsWith(version.path)),
18
+ );
19
+
20
+ const shouldRenderAlternateLink = currentPath && currentPath !== '404' && !isVersionedPage;
14
21
 
15
22
  const alternateMarkdownLink = useBaseUrl(`/${currentPath}.md`, { absolute: true });
16
23