Skip to content

Commit b62ecba

Browse files
author
Adam Spiers
committed
Make local file:... links navigate to the relevant file
Make a link like [[file:foo/bar.org][bar]] into href="foo/bar.org" without target="_blank", so that it opens in the same organice window. This allows more convenient navigation around a network of .org files, and in particular an index.org file which facilitates quick jumping to the most commonly used other .org files.
1 parent 274d35c commit b62ecba

File tree

1 file changed

+7
-2
lines changed
  • src/components/OrgFile/components/AttributedString

1 file changed

+7
-2
lines changed

src/components/OrgFile/components/AttributedString/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ export default ({ parts, subPartDataAndHandlers }) => {
2020
case 'link':
2121
const uri = part.getIn(['contents', 'uri']);
2222
const title = part.getIn(['contents', 'title']) || uri;
23-
23+
const isFileLink = uri.startsWith("file:");
2424
return (
25-
<a key={part.get('id')} href={uri} target="_blank" rel="noopener noreferrer">
25+
<a
26+
key={part.get('id')}
27+
href={isFileLink ? uri.substr(5) : uri}
28+
target={isFileLink ? "" : "_blank"}
29+
rel="noopener noreferrer"
30+
>
2631
{title}
2732
</a>
2833
);

0 commit comments

Comments
 (0)