question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to auto generate sidebar in vuepress component

See original GitHub issue

Feature 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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
JStumppcommented, Jun 19, 2019

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.

0reactions
iamchriswickcommented, Apr 8, 2021

Why is this closed when there no solution for it?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found