I'm learning how to use Nuxt to build generate a static blog, and I came across the piece of code bellow to create the page containing a list of posts:
<script>
export default {
async asyncData() {
const resolve = require.context("~/content/", true, /\.md$/)
const imports = resolve.keys().map((key) => {
const [, name] = key.match(/\/(.+)\.md$/);
return resolve(key);
});
return {
posts: imports
}
},
}
</script>
I understand what it does: getting a list of all the markdown files and map their keys to the file's name, but I don't understand what const [, name]
means, actually what the coma inside the array means.
can somebody explain it to me, please?
Thanks.
Noah