I have a a lot of GPX track logs. In order to display them on mapbox in my hugo site I need to convert them to GeoJSON. I have java script libraries and command line utils that can do the conversion so I don’t need hugo to actually do the conversion.
I’m just wondering if there is a “Build Hook” (I don’t know the right terminology) in hugo to run a special build script for changes to files of a certain type and output them to the public static folder for example.
I think I could use webpack or CMake to do this but I’m not that familiar with those tools.
Is there a straight forward Hugo-esque way to accomplish this just with Hugo?
If you update the files from external tool imho Hugo server should detect that
If you have a js api you could chain the js calls.
One to convert log to json string
Second call mapbox api.
Theortically you could use template functions to convert your logs to json and render page resources with a content adapter. But guess thats not practical
I think " templating functions" may be what I’m trying now. Could you tell me more about how you would approach that or perhaps docs that I’ve missed or didn’t understand?
depending on the input and output format that may become a quite complex scenario. Hugo is not a text-processing engine, so it may be hard to code and guess will be slower than specialized processing engines…
nevertheless I thought of
load the logfile (I seem it’s a simple but structured text file) as a resource (resource.Get)
use string methods (find, regex, split…) to split that up in lines (or else) depending on the content layout
extract the fields and store it
in a json string
or
a data structure matching your target JSON format and convert to json string
render as a resource to disk that to using a Content adapters | Hugo.
if you provide a log, a json target file and – if not obvoius – the mapping I could maybe setup something to get you an idea…
will be a nice learning experience although I think an extarnal conversion would be more practical