FIX Rewrite API links for the correct version.

CMS3 docs shouldn't link to CMS4 API, for example.
This commit is contained in:
Guy Sartorelli 2022-07-22 12:16:51 +12:00
parent a0de65a48a
commit 4b9c88219b
1 changed files with 3 additions and 1 deletions

View File

@ -1,9 +1,11 @@
import { getCurrentVersion } from './nodes';
/** /**
* If an href is preceded with api:, rewrite it to the api.silverstripe.org site * If an href is preceded with api:, rewrite it to the api.silverstripe.org site
* @param link * @param link
*/ */
const rewriteAPILink = (link: string): string => { const rewriteAPILink = (link: string): string => {
const version = 4; const version = getCurrentVersion();
const match = link.match(/api\:(.*)/); const match = link.match(/api\:(.*)/);
if (!match) { if (!match) {
console.error(`Unable to resolve api link ${link}!`); console.error(`Unable to resolve api link ${link}!`);