question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Linking to other components

See original GitHub issue

I could be completely missing this in the documentation, but I can’t see where there is a way to have handlebars / MD in a components notes file render a link to another component.

i.e.

This is a description of how this component works. But it's also
similar to {{ components.buttons.cancel-button }}  

Am I just being blind/dumb ?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
mihkeleidastcommented, May 2, 2020

Reopening since this is something we should figure out with integrating core/theme/adapter somehow.

I see the need for three usecases:

  • linking from component templates (this should be implemented by a helper in adapter)
  • linking from docs pages - same as component template
  • adding links to context from the config file. sometimes we need to statically link together two view templates, for example, without using helpers in templates, since the url/href should be a simple context value.
1reaction
LeBenLeBencommented, Oct 7, 2018

If that is of any help, I have this Nunjucks helper:

    link(handle) {
      const name = handle.replace('@', '');
      let prefix = '';
      let ext = '';

      if (process.env.NODE_ENV === 'production') {
        prefix = '../..';
        ext = '.html';
      }

      return `<a href="${prefix}/components/detail/${name}${ext}">${handle}</a>`;
    },

Which then allows me to link to other components with: {{ '@handle' | link }}.

Notice that I run my Fractal commands prefixed with NODE_ENV=[development|production] for this to work properly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Linking to other components with react-router - Stack Overflow
Here is how you can do the desired, simple setup that you want: import React from "react"; import ReactDOM from "react-dom"; ...
Read more >
How to link a custom React component <MyButton> to another ...
Example: The simplest way to redirect a user to another page without the use of any external libraries is to embed the react...
Read more >
React Router Tutorial – How to Render, Redirect, Switch, Link ...
The Redirect component from React Router can be used to redirect the user to another path. const withAuth = (Component) => { const ......
Read more >
Creating a Link Between Pages in React Router
The new List page uses a React Router Link component to navigate to our Detail page. Buy the book for $10. Get the...
Read more >
Link - React Router: Declarative Routing for React.js
A string representation of the Link location, created by concatenating the location's pathname, ... Get the underlying ref of the component using React....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found