Skip to content

Commit 5aab72d

Browse files
authored
fix: Full URL to alternate md links (#2024)
Closes #1982
1 parent 00559a5 commit 5aab72d

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
let absoluteUrl = 'https://docs.apify.com';
2+
3+
if (process.env.LOCALHOST) {
4+
absoluteUrl = 'http://localhost:3000';
5+
} else if (process.env.DEV) {
6+
absoluteUrl = 'http://docs.apify.loc';
7+
} else if (process.env.APIFY_DOCS_ABSOLUTE_URL) {
8+
absoluteUrl = process.env.APIFY_DOCS_ABSOLUTE_URL;
9+
}
10+
11+
exports.absoluteUrl = absoluteUrl;

apify-docs-theme/src/config.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
/* eslint-disable global-require */
2-
3-
let absoluteUrl = 'https://docs.apify.com';
4-
5-
if (process.env.LOCALHOST) {
6-
absoluteUrl = 'http://localhost:3000';
7-
} else if (process.env.DEV) {
8-
absoluteUrl = 'http://docs.apify.loc';
9-
} else if (process.env.APIFY_DOCS_ABSOLUTE_URL) {
10-
absoluteUrl = process.env.APIFY_DOCS_ABSOLUTE_URL;
11-
}
2+
const { absoluteUrl } = require('./absoluteUrl');
123

134
const noIndex = ['true', '1'].includes(process.env.NO_INDEX ?? '');
145

apify-docs-theme/src/theme/Layout/index.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
66
import { usePluginData } from '@docusaurus/useGlobalData';
77
import React from 'react';
88

9+
import { absoluteUrl } from '../../absoluteUrl';
10+
911
export default function LayoutWrapper(props) {
1012
const { options: { subNavbar } } = usePluginData('@apify/docs-theme');
1113
const baseUrl = useBaseUrl('/');
@@ -17,7 +19,7 @@ export default function LayoutWrapper(props) {
1719
<Head>
1820
{
1921
shouldRenderAlternateLink
20-
? <link rel="alternate" type="text/markdown" href={`${currentPath}.md`}/>
22+
? <link rel="alternate" type="text/markdown" href={`${absoluteUrl}/${currentPath}.md`}/>
2123
: null
2224
}
2325
</Head>

0 commit comments

Comments
 (0)