Skip to content

Commit

Permalink
Make local file:... links navigate to the relevant file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Adam Spiers committed May 29, 2020
1 parent 591b13c commit 216b31a
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/components/OrgFile/components/AttributedString/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ export default ({ parts, subPartDataAndHandlers }) => {
case 'link':
const uri = part.getIn(['contents', 'uri']);
const title = part.getIn(['contents', 'title']) || uri;

return (
<a key={part.get('id')} href={uri} target="_blank" rel="noopener noreferrer">
{title}
</a>
);
if (uri.startsWith("file:")) {
return (
<a key={part.get('id')} href={uri.substr(5)} rel="noopener noreferrer">
{title}
</a>
);
} else {
return (
<a key={part.get('id')} href={uri} target="_blank" rel="noopener noreferrer">
{title}
</a>
);
}
case 'percentage-cookie':
className = classNames('attributed-string__cookie-part', {
'attributed-string__cookie-part--complete':
Expand Down

0 comments on commit 216b31a

Please sign in to comment.