markdownpedia
markdownpedia copied to clipboard
Is the script to format the URL necessary?
First I'm sorry for the English.
- Problem: I was trying to run the project locally but I was having trouble getting the css to load.
I realized that what was generating this error was the javasscript scripts in the templates.html file:
var source = document.getElementById('icon').href.replace('markdownpedia.tk', window.location.hostname);
document.getElementById('icon').href = source;
source = document.getElementById('style').href.replace('markdownpedia.tk', window.location.hostname);
document.getElementById('style').href = source;
var tag = document.createElement('script');
var things = 'https://markdownpedia.tk/server/vital/search.js';
tag.src = things.replace('markdownpedia.tk', window.location.hostname);
document.getElementsByTagName('head')[0].appendChild(tag);
It swaps the host from markdownpedia.tk to the local host, but does not change the protocol. As it was running locally the protocol used is http, but to load the css it used https.
So analyzing the code more I realized that this script is not necessary, (or maybe it is depending on how you are hosting the site, in this case i'm sorry for opening this issue), because HTML itself is already capable of doing this replacement.
-
Solução: Perform the following steps for the equivalent cases in the project
- 1 Remove the url formatting script
- 2
<!-- Replace this --> <link id="style" rel="stylesheet" href="https://markdownpedia.tk/server/vital/style.css" /> <!-- For this --> <link id="style" rel="stylesheet" href="/server/vital/style.css" />
OBS: If this is confirmed as a problem and not something intentional, I put myself at your disposal to make a PR fixing the problem
This is an issue, I created that script because I didn't want the sites css to be used. While you can do server/vital/style.css
as the source, I was planning on changing the css URL, so I wasn't sure what to do. If you'd like to replace all the references with relative URLs, you can go right ahead and do so. Thanks for your help.
Hi, the task seems to me necessary, if it is free, I could try to do it?