hugo-leaflet icon indicating copy to clipboard operation
hugo-leaflet copied to clipboard

Fails to load locally required JS

Open anoduck opened this issue 4 years ago • 4 comments

Attempting to get this library to render a map and so far it has not worked out. This might be an issue that is specific to the hugo theme that I am incorporating. It facilitates postcss.js, which could be preventing the library from loading.

First off, I am unsure whether the library's files should be placed within the theme or within the site itself. You mentioned modifying the partial head.html, but did not clarify if we are to modify and save it to site/layouts/partials or whether we are to save it to site/themes/ourtheme/layouts/partials. The same for the css, imgs, and js. Do they belong in the theme or in the site, and do the js files need to be placed in /assets/js or in /static/js?

I have tried both ways and all at once, and the best that I receive is an error output that resembles "leaflet.elevation.{{$HASH}}.js cannot be loaded".

anoduck avatar Sep 21 '21 21:09 anoduck

You can save it to site/layout/partials and /asset/js/. I used library in this project

altrdev avatar Oct 06 '21 16:10 altrdev

My apologies, your project is a brilliant contribution to Hugo, and now works. I should have closed this issue out weeks ago.

In order to employ use of the project, I wound up creating a shortcode for it.

But, while I am thinking of it. Is there anyway to load the coordinates for markers and map from a JSON file?

anoduck avatar Oct 08 '21 10:10 anoduck

Hi @anoduck, can you maybe share that shortcode? I can't get the map to run either, unfortunately with my theme? When I add the shortcode {{< leaflet-map mapHeight="500px" mapWidth="100%" mapLat="27.66995" mapLon="85.43249" >}} nothing is being rendered. The only console error I am getting is (index):76 Uncaught ReferenceError: leafletMapsObj is not defined at (index):76. I think the leafletMapsObj is related to the mapID that is generated automatically? Any help is very much appreciated!

Dkp22 avatar Oct 21 '21 13:10 Dkp22

Sorry for my late response @Dkp22, to say the least, life has been too busy.

OK, so...a little heads up...I hacked this, it is not going to be pretty.

Here is the gist I created from the shortcode and the page.

leaflet-hugo shortcode

Hope this helps out. Everyone has their own way of doing things, sometimes that way does not jive, and other times it does. So is life...

anoduck avatar Oct 24 '21 11:10 anoduck

No matter what I do, I also can't get this to work. Console keeps showing the error leafletMapsObj is not defined.

It would be wonderful if this repo and the installation instructions could be updated.

pensivedog avatar Aug 28 '23 14:08 pensivedog

Finally was able to get this working with the fixes here:

https://github.com/altrdev/hugo-leaflet/pull/9

pensivedog avatar Aug 28 '23 14:08 pensivedog

@pensivedog Glad you took the initiative, and took care of business. I was rather disposed yesterday. Cheers.

anoduck avatar Aug 29 '23 20:08 anoduck

I guess it is well past time for me to close this one out.

anoduck avatar Aug 29 '23 20:08 anoduck