Closed MarvinMiles closed 5 months ago
I'm unable to replicate this on 3.0.0-next.199
and 3.0.0-next.205
.
In my src/routes/posts/index.md
:
<!-- routify:meta _test="test" -->
<script>
import {node, meta} from '@roxi/routify'
export let context
</script>
{$meta._test}
{$node.meta._test}
{context.node.meta._test}
This prints test test test
Are you by any chance trying to get the index
meta data from the posts
folder? If so, _module.svelte|md
represents the folder.
@jakobrosenberg Thanks. Got you... almost.
So how can I get meta data of active route inside _module.svelte
file?
Got a working solution by $activeRoute.fragments[$activeRoute.fragments.length-1].node.meta
, but this looks ugly and overheady.
Use case would be managing <svelte:head>
inside _module file.
For example:
<svelte:head>
<title>{ $activeNode.title }</title>
<meta content="{ $activeNode.meta.description }" name="description" />
</svelte:head>
Ok $activeRoute.meta
solves the issue.
Yet how can I get title (file name) of activeRoute?
@MarvinMiles, assuming you mean the file name of the leaf component, you can try
$activeRoute.leaf.node.file
Describe the bug
For example: I have a route folder
posts
with two files:index.md
andarticle.md
inside. Adding inlinined meta works only forarticle.md
. Trying to get meta fromindex.md
returns empty object.<!-- routify:meta _test="test" -->
Reproduction
Create route folder
posts
with two files:index.svelte
andarticle.svelte
inside. Then write<!-- routify:meta _test="test" -->
inside those files and try to get this data on each route.Logs
No response
System Info