Coder Social home page Coder Social logo

Comments (4)

jakobrosenberg avatar jakobrosenberg commented on September 1, 2024 1

@MarvinMiles, assuming you mean the file name of the leaf component, you can try

$activeRoute.leaf.node.file

from routify.

jakobrosenberg avatar jakobrosenberg commented on September 1, 2024

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.

from routify.

MarvinMiles avatar MarvinMiles commented on September 1, 2024

@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>

from routify.

MarvinMiles avatar MarvinMiles commented on September 1, 2024

Ok $activeRoute.meta solves the issue.

Yet how can I get title (file name) of activeRoute?

from routify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.