Closed scottandrewlepera closed 1 month ago
This is by design! I have to have a single page to route the incoming traffic from the previous/next sites when they try to go to your site.
If you want to change the behavior however, there is a workaround I use to match sites for folks using Google Sites since the domains are kinda wonky. If you add a custom JavaScript file in the the custom/
directory like comics-yuki.js, you can hardcode in your site's URL so that the buttons still work on all your subpages work and other sites will still point to your home page!
Let me know if this solves your problem!
Oh, I think I understand: the URL field in the JSON is a landing page, not just the domain (there are even examples of this in the current file, d'oh!). I'm not sure I follow why the safety check is against the landing page URL instead of just the domain (since all of my pages would be under that domain and you could extract that from the JSON field?). I get significant traffic to individual comics posts so I would be cool to have the widget work from pages other than the specified landing page.
But the workaround seems like a lot of extra code to maintain just to hardcode a URL! I think I'll just have this live on my homepage for now.
Feel free to resolve, thanks!
The reason for using the URL is because some people have stressing for different lines on different subpages! The URL doesn't have to specifically be for your homepage 😁
I didn't plan on changing things up so there shouldn't be much maintenance for adding a custom script! Feel free to add one. There are only three lines that need to be changed, happy to point them out, & two of them are already changed in the comics-yuki.js file I linked above! The third is just providing the main redirect page for other sites to link to you.
Okay, I'll post a PR if I decide to go the custom route. Thanks again!
Will close now.
Hey @scottandrewlepera, just wanted to let you know that I came up with a solution for folks that want to have a working widget on multiple pages of their site! What you need to do is add an additional <script>
tag to your HTML defining forceURL_comics
like the following:
<script> let forceURL_comics = "neathobby.com/"; </script>
<script src="https://github.com/GusBusDraws/smallweb-subway.js/comics.js"></script>
<smallweb-subway-comics></smallweb-subway-comics>
The forced URL in this case doesn't have to be the only place the widget is added! It will just mean that any other pages will be able to use this URL as the "key" to find the right position in the comics site list!
Let me know if you have any questions!
It looks like the widget only works on pages where the URL exactly matches the submitted URL recorded in the corresponding JSON file. This prevents the widget from being included across pages in shared layout elements like sidebars and footer navigation. Specifically, it looks like the code attempts to use the hostname + path as the lookup key and throws a console error when it fails:
https://github.com/GusBusDraws/smallweb-subway.js/blob/main/comics.js#L150
If this is by design, feel free to close this issue. I only checked the Comics line code.
Repro steps
Expected
I should be taken to the next (or previous) site
Actual
Nothing happens. Console log reads: "Uncaught TypeError: matchedSite_comics is undefined"
Suggested
Widget works as it does on homepage, or the widget is not rendered at all. The error should be caught and logged at least so it doesn't break other JS that may be used by the page.