Skip to content

Vuepress interpolated anchors #2379

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

Open
1 task done
salazarr-js opened this issue May 8, 2020 · 0 comments
Open
1 task done

Vuepress interpolated anchors #2379

salazarr-js opened this issue May 8, 2020 · 0 comments

Comments

@salazarr-js
Copy link

  • I confirm that this is an issue rather than a question.

Bug report

Markdown title anchors don't work well with vue text interpolation.
When using {{ }} vue text interpolation in titles or headings, the markdown.anchors plugin doesn't generate correct slugs.

Steps to reproduce

https://codesandbox.io/s/vuepress-interpolated-anchors-j34bb?file=/README.md

  1. Add some vue data variables in a script or in the frontmatter block
---
title: Vuepress interpolated anchors
---

<script>
export default {
  data: function() {
    return {
      subTitle: 'Interpolated headings examples'
    }
  }
}
</script>
  1. Use them in some headings with vue text interpolation
# {{ $frontmatter.title }}

## {{ subTitle }}

What is expected?

We can expect that the anchors are the slug version of the content of the variables,

<h1 id="vuepress-interpolated-anchors">
  <a href="#vuepress-interpolated-anchors">#</a>
  ...
</h1>

<h2 id="interpolated-headings-examples">
  <a href="#interpolated-headings-examples">#</a>
  ...
</h2>

What is actually happening?

The anchors are the slug version of the variable name, no of its content

<h1 id="frontmatter-title">
  <a href="#frontmatter-title">#</a>
  ...
</h1>

<h2 id="subtitle">
  <a href="#subtitle">#</a>
  ...
</h2>

Other relevant information

Environment Info:
  System:
    OS: macOS 10.15.3
    CPU: (4) x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz
  Binaries:
    Node: 12.16.1 - /usr/local/opt/node@12/bin/node
    Yarn: Not Found
    npm: 6.13.4 - /usr/local/opt/node@12/bin/npm
  Browsers:
    Chrome: 81.0.4044.138
    Firefox: Not Found
    Safari: 13.0.5
  npmPackages:
    @vuepress/core:  1.4.1
    @vuepress/theme-default:  1.4.1
    vuepress: ^1.4.1 => 1.4.1
  npmGlobalPackages:
    vuepress: 1.4.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant