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.

Relative path links from notes accessible both from local server as deployed server.

See original GitHub issue

What problem would this feature solve?

Possibility to access components via the same relative path (with extension) between the local development server and the build variant being hosted elsewhere.

Right now, if you put a relative URL in the notes pointing to another component, for instance: ./component-name, it will work fine on the local development server. The default settings on the builder make it work so it contains the extension (.html). Therefore when you host the build variant elsewhere, your notes with the ./component-name the link will result in a 404.

Vice versa this has the same effect, so if we would construct the link to contain the extension, as such: ./component-name.html, this will work fine in the build variant. But this won’t work in the local development server as it will try and match the handle including the extension (stating: Not found - Component ‘component-name.html’) not found.

It would be a bit more decent, functionality-wise, if these inner links don’t break depending on the environment its on.

What the feature should look like?

A possible solution is to overwrite the default extension the builder script receives from the config, and change the htaccess file to point towards the extension-less build files, this is already implemented. But, as is the case in my current environment, I don’t have the opportunity to go and modify that. Therefore, why not have the possibility to inverse this mechanism from the local environment as well?

From the config, it could supply an extension (by default ‘.html’) which then gets retrieved in the local server and somehow knows how to match the appropriate component. That way he will strip off the extension and can match the handle accordingly.

Proposed solution (direction): #659 - see discussion below on cleanliness

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
mihkeleidastcommented, Sep 8, 2020

That should be a bug in the path helper in the handlebars adapter, since it should do an early return for server - see here. I’m pretty sure this worked when I fixed the related bug though, not sure what has changed since then.

Either way, using the path helper should be the correct way, and this bug in the path helper should rather be fixed than worked around via a new option.

1reaction
mihkeleidastcommented, Sep 8, 2020

Yeah I’d like to understand the issue better so I could maybe suggest a better fix. I can wait for the repro for a bit 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Relative and absolute paths, in the file system and on the web ...
Your site exists in two realms at once: the real and the virtual one. For the site visitors it's entirely a virtual server,...
Read more >
Deploying to Github Pages? Don't Forget to Fix Your Links
Root-relative links ignore their current path and they don't follow location changes. The same thing happens when you develop your site locally and...
Read more >
Application Root is your friend - · Los Techies
Using application root paths allows me to: Develop locally and deploy to production seamlessly; Have consistent URL per resource; Use raw HTML ...
Read more >
Creating hyperlinks - Learn web development | MDN
A quick primer on URLs and paths ... To fully understand link targets, you need to understand URLs and file paths. This section...
Read more >
Relative URLs in WordPress - Stack Overflow
Keeps the path '/' at the beginning, so it isn't a true relative link, ... I've once used this plugin for relative paths,...
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