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.

Please add support for nested page frontmatter data and link data

See original GitHub issue

Is your feature request related to a problem? Please describe. For custom themes such as blogs, it is useful to have access to the directory structure and frontmatter data for nested pages. For example, if I have the following directory structure:

/blog/index.md
/blog/post_1.md
/blog/post_2.md

Then I would like to be able to create a clickable list of posts on the /blog/index page with information for nested posts such as the post title, date, etc.

To do this, I need to be able to retrieve the frontmatter data from post_1 and post_2 (titles, dates) as well as information about what nested pages (i.e. links) are available.

At the moment I see no way to see frontmatter or site structure information other than for the currently selected page?

I realise that the current goal is to keep vitepress simple and lightweight, however, this change would make vitepress viable for themes such as blogs without IMHO complicating the conceptual purity of the package.

Describe the solution you’d like

  • A site-level property in siteData containing information about the nested page structure (for building links).
  • A site-level property in siteData containing frontmatter data for each page.

Describe alternatives you’ve considered I’ve looked around siteData and other locations, but don’t currently see a way to recover this information. (Please let me know if there is a way!!)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
songololocommented, Nov 5, 2020

Vitepress points the way forward (vite as opposed to webpack) and so there will only be growing interest in using vitepress more extensively.

I agree that the framework should remain minimal and focused on what it does so that the code base remains lean and because this lets us easily tweak or tailor to our own use cases per theme customisation (without getting bogged down in technicalities).

However, some basic site-wide information is really useful in certain contexts such as blogs or situations like nested documentation sites, and allows for a much more expressive use of the package. Some thoughts:

  • A site-wide property containing information about available paths and front matter would be the easiest from a user’s point of view
  • Maybe a plug-in of sorts could inject this functionality so that it is available to various themes that will inevitably be built with vitepress (without each theme having to reinvent the wheel)?
  • If this is left to the theme developer to implement on a theme-by-theme basis then it would be helpful to have a small how-to in the documentation showing a best-practices-like approach towards finding the relevant bits and pieces to extract this information from within the theme itself.

EDIT: It can also be argued that a property with site-wide information about path’s and frontmatter actually favours a lean paradigm because things like sidebars, navbars, and page content can be built dynamically for respective themes without needing to overload the configs file with assorted manual configurations, which are prone to bugs.

1reaction
neilmispelaarcommented, Dec 6, 2020

If I may: beyond the “thumbs up” that I added to the post above, I too would really like to echo support for this feature / enhancement request.

For context, I am (and imagine a few others are as well) building a blog with vitepress and so far everything has been absolutely fantastic.

This feature would make it much easier when it comes to generating the lists of articles on the home page in a custom theme.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Display Values from Nested YAML Frontmatter
Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials...
Read more >
Adding Content - Docsy
Hugo builds your site pages using the content files you provide plus any templates provided by your site's theme. These templates (or “layouts” ......
Read more >
liquid - Jekyll Nested Data
I use this to print additional information after each post, which I specify in the front matter. This works fine. I now wish...
Read more >
I Finally Understand Eleventy's Data Cascade. - Ben Myers
I've documented my whole mental model of Eleventy's data cascade. ... for me in our session on "Add to Calendar" links with computed...
Read more >
DataviewJS Snippet Showcase
entry in the YAML frontmatter. (This syntax has something to do with YAML & JS data structure and easy parsing. The sequence [lat,...
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