Skip to content

Support relativePath link set linkTarget #1750

Closed

Description

@bilibiliou

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

Activity

  1. changed the title [-]Support RelativePath link compile[/-] [+]Support relativePath link jump[/+] on Feb 12, 2022
  2. changed the title [-]Support relativePath link jump[/-] [+]Support relativePath link set linkTarget[/+] on Feb 12, 2022
  3. bilibiliou commented on Feb 12, 2022

    @bilibiliou
    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}"`
              : ''
          );
        }
  4. Koooooo-7 commented on Feb 13, 2022

    @Koooooo-7
    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. :)

  5. bilibiliou commented on Feb 13, 2022

    @bilibiliou
    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions