joeyespo / grip

Preview GitHub README.md files locally before committing them.
MIT License
6.5k stars 424 forks source link

How to use custom local CSS file? #342

Open nluetts opened 3 years ago

nluetts commented 3 years ago

Hi,

I would like to make grip use a local CSS file on my hdd. I am trying to (mis?)use the STYLE_URLS setting for that and add an entry "custom.css". The file custom.css is in the same folder as the markdown file I want to preview.

The style in custom.css is not loaded when opening the grid page in the browser. In the HTML source code I can see that custom.css was added to the urls that shall be loaded, and I can even click on the entry and the dev server takes me to the file. However, the CCS code is then embedded in some HTML. Appropriately, opening the browser console on the markdown preview reveals that the browser complains:

The stylesheet http://localhost:6419/custom.css was not loaded because its MIME type, “text/html”, is not “text/css”. REPORT.md

So I have access to the CSS file, but it is parsed incorrectly. If I click on any other CSS file in the list of style sheets, their source is displayed as plain CSS.

Clearly, I am doing something wrong here -- can you help me out?

tkin91e55 commented 2 years ago

I encountered issue #347 , I tried to use #333 grip-style.css (your custom.css) as workaround, my ~/.grip/settings.py is like:

STYLE_URLS = ['/__/grip/asset/custom.css']

And put the custom.css under ~/.grip/cache-{version}/

If still not working, may try to delete all other \<link rel="stylesheet" href="others.css"> at the rednered page.