Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

How would you get a list of posts including metadata? #158

Closed
didier opened this issue Oct 18, 2020 · 1 comment
Closed

How would you get a list of posts including metadata? #158

didier opened this issue Oct 18, 2020 · 1 comment

Comments

@didier
Copy link

didier commented Oct 18, 2020

I want to get a list of all posts in my /posts directory as well as each post's metadata. However, I can't seem to find anywhere to point me in the right direction. i don't have a .json post index to map over, and I don't want to use one either. I should mention I previously got this working with @jackfranklin/rollup-plugin-markdown using the following syntax:

import allPosts from './posts/*.md'

In short: when I create a new md file, I want that post to show up in a posts list

Essentially, I want

/posts
  first-post.md
  second-post.md

to turn into something like this on the front-end

My Blog

1. First Post
2. Second Post
@Pytal
Copy link

Pytal commented Dec 14, 2020

I'm currently using import-all.macro simply because the alternatives I've found are not as actively maintained but have also used babel-plugin-import-glob-array. Something like the snippet below would work.

import importAll from 'import-all.macro'

export const posts = Object.entries(importAll.sync('./posts/*.svx'))

@pngwn pngwn closed this as completed Mar 27, 2021
Repository owner locked and limited conversation to collaborators Mar 27, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants