Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support relativePath link set linkTarget #1750

Closed
bilibiliou opened this issue Feb 12, 2022 · 3 comments · Fixed by #1751
Closed

Support relativePath link set linkTarget #1750

bilibiliou opened this issue Feb 12, 2022 · 3 comments · Fixed by #1751

Comments

@bilibiliou
Copy link

bilibiliou commented Feb 12, 2022

Hi
When I read the docs of "Set target attribute for link" https://docsify.js.org/#/helpers?id=set-target-attribute-for-link
I try a relative path to jump

[demo](/docs/front_end/summery_of_experience/data_use/assets/demo/index.html ':target=_blank')

but It be compiled as

<a href="/docs/front_end/summery_of_experience/data_use/assets/demo/index.html">demo</a>

It is not my expectation.

After then, I read the source code: "src\core\render\compiler\link.js" line 22
I discover that docsifyjs didnt support relative path linkTarget custom

so I make the issue in order to discuss the problem

thx

@bilibiliou bilibiliou changed the title Support RelativePath link compile Support relativePath link jump Feb 12, 2022
@bilibiliou bilibiliou changed the title Support relativePath link jump Support relativePath link set linkTarget Feb 12, 2022
@bilibiliou
Copy link
Author

"src\core\render\compiler\link.js" line 22

if (
      !isAbsolutePath(href) && // If it is relative path, then cant set linkTarget
      !compilerClass._matchNotCompileLink(href) &&
      !config.ignore
    ) {
      if (href === compilerClass.config.homepage) {
        href = 'README';
      }

      href = router.toURL(href, null, router.getCurrentPath());
    } else {
      if (!isAbsolutePath(href) && href.slice(0, 2) === './') {
        href =
          document.URL.replace(/\/(?!.*\/).*/, '/').replace('#/./', '') + href;
      }
      attrs.push(href.indexOf('mailto:') === 0 ? '' : `target="${linkTarget}"`);
      attrs.push(
        href.indexOf('mailto:') === 0
          ? ''
          : linkRel !== ''
          ? ` rel="${linkRel}"`
          : ''
      );
    }

@Koooooo-7
Copy link
Member

Thx for ur report.
Unfortunately, docsify doesn't support the relative target config for now.
I think we may have an update on it asap. :)

@bilibiliou
Copy link
Author

Okay, thx ur reply and support
I can use the absolute link instead now.
hope you have a nice day :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants