NuxtN
Nuxt11mo ago
Dog

Actual files not showing with Content v3

I have 2 Markdown files in /content/jobs, and I'm just trying to show them in a list in a page, but I can't figure out how to do this. Everything I've tried has either errored somewhere, or only showed one result, with a title of Jobs and a path of /jobs.

Here's my current code, copied from the docs and slightly modified:

pages/jobs/index.vue
:
<script setup lang="ts">
const { data } = await useAsyncData('navigation', () => {
    return queryCollectionNavigation('jobs', ['description']).order('title', 'ASC');
});
</script>

<template>
    <nav class="flex flex-col gap-4 p-8 pt-[115px]">
        <ul v-if="data">
            <li v-for="item in data" :key="item.path">
                <NuxtLink :to="item.path">
                    {{ item.title }}
                </NuxtLink>
                <p v-if="item.description">{{ item.description }}</p>
            </li>
        </ul>
        <p v-else>Nothing found</p>
    </nav>
</template>


/content.config.ts
:
import { defineContentConfig, defineCollection } from '@nuxt/content';

export default defineContentConfig({
    collections: {
        jobs: defineCollection({
            type: 'page',
            source: 'jobs/*.md',
        }),
    },
});


The result of this is attached
image.png
image.png
image.png
Was this page helpful?