How to auto generate sidebar in vuepress component
See original GitHub issueFeature request
What problem does this feature solve?
this is my readme.md file
---
#blog_index: true
sidebar: auto
---
<IndexByCategory />
this is my IndexByCategory Component
<template>
<div>
<div v-for="(posts,postTag,index) in postsResult">
<h2 :id="postTag"><a href="#" aria-hidden="true" class="header-anchor">#</a> {{postTag}}</h2>
<div v-for="post in posts">
<h3>
<router-link :to="post.path">{{ post.frontmatter.title }}</router-link>
</h3>
<p>{{ post.frontmatter.description }}</p>
<p>
<router-link :to="post.path">Read more</router-link>
</p>
<hr>
</div>
</div>
</div>
</template>
<script>
export default {
computed: {
postsResult() {
var tagSort = new Object();
var filteredPages=this.$site.pages.filter(x => x.path.startsWith('/blog/'));
//console.log(this.$site["pages"]);
filteredPages.forEach(element => {
if(element["frontmatter"]["tags"]==undefined){
console.log(element["title"]+" don't have tags in frontmatter!");
}
element["frontmatter"]["tags"].forEach(element2 => {
if (tagSort[element2] == undefined) {
tagSort[element2] = new Array();
}
tagSort[element2].push(element);
});
});
//console.log(tagSort);
return tagSort;
}
}
}
</script>
I want to generate a tag as a markdown head in component so that I can use sidebar:auto to generate a sidebar,but I don’t know the fastest way to realize it.
What does the proposed API look like?
give a way to realize a sidebar anchor in vuepress component.maybe it is a component too.
How should this be implemented in your opinion?
use a vuepress component like makrdown header # ,## ,###
Are you willing to work on this yourself?**
no,I don’t have much time to write it.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Automatic Dynamic Sidebars in Vuepress
The plugin vuepress-plugin-auto-sidebar seemed to do exactly what I wanted. ... Let's get this going. Go to Vuepress folder and install package.
Read more >Default Theme Config
To automatically generate a sidebar that contains only the header links for the current page, you can use YAML front matter on that...
Read more >How to make vuepress dynamically create the side ...
The way I worked around it so far is to configure theme-config to do this which removes the errant modules. sidebar: sidebar .getSidebar()...
Read more >Getting started | Vuepress Plugin Auto Sidebar - GitHub Pages
This is a plugin that automatically generates a sidebar for vuepress. If you just write a simple page, just use the native sidebar...
Read more >vuepress-plugin-auto-sidebar
A vuepress plugin for generate sidebar. Latest version: 2.3.2, last published: a year ago. Start using vuepress-plugin-auto-sidebar in your ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same problem here. We generate page content (including headers like h2, h3) from a json file, example here: https://docs.movisens.com/movisensXS/mobile_sensing/#features-library-version-version
Having no sidebar and no search for this content is a huge problem for us. @ulivz, do you have a suggestion? Thank you so much.
Why is this closed when there no solution for it?