TorstenDittmann / svelte-markdoc-preprocess

Bring the power of Markdoc right into your Svelte applications!
https://svelte-markdoc-preprocess.pages.dev
MIT License
65 stars 4 forks source link

Non-default layout component throws warning #218

Open maiertech opened 2 months ago

maiertech commented 2 months ago

Describe the bug

I have an app with default.svelte layout and an alternative docs.svelte layout.

The docs layout can be applied by adding layout: 'docs' to a page. The docs layout component receives all frontmatter properties as component props, including layout. This is expected behavior but it triggers a warning in the console:

<Docs> was created with unknown prop `layout`.

Because my docs.svelte does not expect a prop layout.

To suppress the warning, I added the following ugly workaround to the <script> tag of the docs.svelte layout:

export let layout: string;
layout;

To Reproduce

Create an alternative layout component without prop layout.

Expected behavior

Maybe do not pass on the layout prop?

Screenshots

n/a

Desktop (please complete the following information):

n/a

Smartphone (please complete the following information):

n/a

Additional context

The alternative layout of the demo, https://github.com/TorstenDittmann/svelte-markdoc-preprocess/blob/main/apps/demo/src/lib/layouts/Alternative.svelte, uses the layout prop to display the layout name. That's why it does not throw the warning in the console. Makes sense for this demo, but not something you would normally do with the layout prop.

TorstenDittmann commented 2 months ago

I agree, not really useful if not used. Will work on a fix in the following week 🙏🏻