N
Nuxt2mo ago
CowLiqour

nuxt content not rendering components properly

---
title: 'MVP development'
---
::content-hero
<div class="flex flex-col md:w-1/2 w-full mt-12 text-balance gap-12">
<div>
::content-title{type="h2"}
Your Vision, Crafted with Care and Precision.
::
</div>
<div>
::content-title
We create tailored
<span
:class="[{ [`bg-[url('/assets/images/swoosh-sharpie.svg')] bg-no-repeat swoosh`]: mounted && colorMode.value === 'light' }]"
class="text-blew">
digital solutions
</span>
for every stage of business,
built with care and designed for growth.
::
</div>
<div>
<span class="font-semibold text-gandalf-700 text-lg">Marijn Wijbenga &#8212; Digital Solutions Architect</span>
</div>
<div class="mt-8 mx-auto sm:mx-0">
::content-button
Get a free consultation
::
</div>
</div>
<div class="md:w-1/2 w-full h-[39rem] hidden md:block">
<div
class="bg-[url('/assets/images/hero-image-wybit.png')]
h-full bg-contain bg-no-repeat bg-right"></div>
</div>
::
---
title: 'MVP development'
---
::content-hero
<div class="flex flex-col md:w-1/2 w-full mt-12 text-balance gap-12">
<div>
::content-title{type="h2"}
Your Vision, Crafted with Care and Precision.
::
</div>
<div>
::content-title
We create tailored
<span
:class="[{ [`bg-[url('/assets/images/swoosh-sharpie.svg')] bg-no-repeat swoosh`]: mounted && colorMode.value === 'light' }]"
class="text-blew">
digital solutions
</span>
for every stage of business,
built with care and designed for growth.
::
</div>
<div>
<span class="font-semibold text-gandalf-700 text-lg">Marijn Wijbenga &#8212; Digital Solutions Architect</span>
</div>
<div class="mt-8 mx-auto sm:mx-0">
::content-button
Get a free consultation
::
</div>
</div>
<div class="md:w-1/2 w-full h-[39rem] hidden md:block">
<div
class="bg-[url('/assets/images/hero-image-wybit.png')]
h-full bg-contain bg-no-repeat bg-right"></div>
</div>
::
this code renders the surrounding component (content-hero) fine, but inside components are rendered like string text for some reason the content-title and content-button components look like this, but even without the nested Ui components they wont render properly
// content-button
<script setup lang="ts">
...props here
</script>

<template>
<UiButton
:layout-type="layoutType"
:button-size="buttonSize"
:button-type="buttonType"
>
<slot></slot>
</UiButton>
</template>

<style scoped>

</style>
// content-button
<script setup lang="ts">
...props here
</script>

<template>
<UiButton
:layout-type="layoutType"
:button-size="buttonSize"
:button-type="buttonType"
>
<slot></slot>
</UiButton>
</template>

<style scoped>

</style>
any guidance as to why this would be happening is greatly appreciated
No description
3 Replies
kapa.ai
kapa.ai2mo ago
Hi @CowLiqour. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the knowledge sources, I can offer some guidance on why your Nuxt Content components are not rendering properly. The issue you're experiencing is likely related to how Nuxt Content handles Vue components within Markdown files. Here are a few key points to consider: 1. Component Location: Nuxt Content expects Vue components used in Markdown to be placed in a specific directory. As mentioned in the Nuxt Content documentation (https://content.nuxt.com/usage/markdown/#vue-components), "Every Vue component created inside the components/content/ directory will be available in Markdown files." 2. Global Components: If you're not using the components/content/ directory, your components need to be marked as global in your Nuxt app. You can find more information about this in the Nuxt 3 documentation (https://nuxt.com/docs/guide/directory-structure/components). 3. Syntax for Using Components: In your Markdown file, you're using the :: syntax to denote components. This is correct according to the Nuxt Content documentation (https://content.nuxt.com/usage/markdown/#block-components). However, make sure you're not mixing this syntax with regular HTML tags within the same block. 4. Nesting Components: Nuxt Content supports nested components, but they need to be properly indented. As shown in the documentation (https://content.nuxt.com/usage/markdown/#nesting), you should indent nested components and potentially add more :::: when nesting deeply. 5. Slots and Content Rendering: For components that accept rich text rendered by Markdown, you should use the <ContentSlot /> component. This is especially important for components that act as wrappers for Markdown content, as explained in the Markdown rendering section (https://content.nuxt.com/usage/markdown/#markdown-rendering) of the documentation. Given these points, here are some suggestions: 1. Ensure your content-hero, content-title, and content-button components are either in the components/content/ directory or marked as global. 2. Try simplifying your Markdown structure to isolate the issue. Start with a basic implementation and gradually add complexity. 3. For nested components, ensure proper indentation:
::content-hero
::content-title{type="h2"}
Your Vision, Crafted with Care and Precision.
::
::

::content-hero
::content-title{type="h2"}
Your Vision, Crafted with Care and Precision.
::
::

4. For components that wrap Markdown content, use the <ContentSlot /> component in your Vue template. If these suggestions don't resolve the issue, it's possible there might be a bug or compatibility issue with the version of Nuxt Content you're using. In that case, you might want to check for any open issues or consider raising a new one in the Nuxt Content GitHub repository (https://github.com/nuxt/content). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@484585894955974657> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
CowLiqour
CowLiqourOP2mo ago
it didnt solve it though but the ::content-hero ::content-title{type="h2"} Your Vision, Crafted with Care and Precision. :: :: does work, so im assuming it doesnt like nested html tags in there, which makes me already hate this markdown path and im going to abandon this path for the rest of my life, content with markdown is bs so solved im thinking, this nuxt content is kind of usefulf or generating thumbnails with some text dynamically for something like services or idk employees or whatever, and the actual page it links to can still be a vue page, which is superior in styling options battling with nuxt content components is just not a good idea
Want results from more Discord servers?
Add your server