mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-06 07:37:56 +02:00
BUGFIX: Fix ctrl-clicking after the doc_en refactor (#2256)
This refactors getPage so that the same code can be used as part of openDocExternally. This is necessary, since looking things up in AllPages is potentially required to determine which language-version of the external page to link to.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import React, { useContext, useState } from "react";
|
||||
import { type FilePath, asFilePath } from "../../Paths/FilePath";
|
||||
import { CONSTANTS } from "../../Constants";
|
||||
import { resolvePage } from "../../Documentation/root";
|
||||
|
||||
interface Navigator {
|
||||
navigate: (s: string, external: boolean) => void;
|
||||
@@ -96,10 +97,17 @@ export function openDocExternally(path: string) {
|
||||
let url;
|
||||
if (path.startsWith("http://") || path.startsWith("https://")) {
|
||||
url = path;
|
||||
} else if (path.startsWith("nsDoc/")) {
|
||||
url = `https://github.com/bitburner-official/bitburner-src/blob/${ver}/markdown/${path.replace("nsDoc/", "")}`;
|
||||
} else {
|
||||
url = `https://github.com/bitburner-official/bitburner-src/blob/${ver}/src/Documentation/doc/${path}`;
|
||||
const title = resolvePage(path).pageName;
|
||||
if (title == null) {
|
||||
return; // An error was already printed to console
|
||||
}
|
||||
url = `https://github.com/bitburner-official/bitburner-src/blob/${ver}/`;
|
||||
if (title.startsWith("nsDoc/")) {
|
||||
url += `markdown/${title.replace("nsDoc/", "")}`;
|
||||
} else {
|
||||
url += `src/Documentation/doc/${title}`;
|
||||
}
|
||||
}
|
||||
window.open(url, "_newtab");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user