Skip to content
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

Non-default layout component throws warning #218

Open
maiertech opened this issue Sep 7, 2024 · 1 comment
Open

Non-default layout component throws warning #218

maiertech opened this issue Sep 7, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@maiertech
Copy link

maiertech commented Sep 7, 2024

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
Copy link
Owner

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

@TorstenDittmann TorstenDittmann self-assigned this Sep 14, 2024
@TorstenDittmann TorstenDittmann added the bug Something isn't working label Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants