kaushalmodi / hugo-search-fuse-js

Hugo theme component for implementing static site search using Fuse.js
https://hugo-search-fuse-js.netlify.app/
GNU General Public License v3.0
68 stars 23 forks source link

Mount external JavaScripts using module system #15

Closed Robin-Wils closed 2 years ago

Robin-Wils commented 2 years ago

hugo mod -get -u should be hugo mod get -u the first command will fail.

Robin-Wils commented 2 years ago

Initialize the hugo module system: hugo mod init github.com/kaushalmodi/hugo-search-fuse-js is also a required step, which is missing in the readme. After that go mod tidy seems to be needed as well. image image

Robin-Wils commented 2 years ago

go mod tidy can be skipped it seems.

Robin-Wils commented 2 years ago

Nevermind I can't get it working. I will stick with the older version for now.

Robin-Wils commented 2 years ago

By the way, it seems like the JavaScript libraries could be linked as module as well, to automatically keep them up to date: https://geeksocket.in/posts/hugo-modules/

Robin-Wils commented 2 years ago

image For some reason if I import the external libs as modules it works fine, but this module does not. The mounts are optional it should mount everything of this repo by default. Not sure why it does not work

config.toml

[module]
[[module.imports]]
  path = "github.com/krisk/Fuse"
[[module.mounts]]
  source = 'dist/fuse.min.js'
  target = 'assets/js/libs/fuse.min.js'  

[[module.imports]]
  path = "github.com/julmot/mark.js" 
[[module.mounts]]
  source = 'dist/mark.min.js'
  target = 'assets/js/libs/mark.min.js'  

[[module.imports]]
  path = "github.com/kaushalmodi/hugo-search-fuse-js"
[[module.mounts]]
  source = 'static'
  target = 'static'
[[module.mounts]]
  source = 'layouts'
  target = 'layouts'
[[module.mounts]]
  source = 'assets'
  target = 'assets'
kaushalmodi commented 2 years ago

Thanks, I'll fix the typo, but you should need to hugo mod init in this repo. You do need to hugo mod init in the repo where you use this module if you are starting to use modules.

kaushalmodi commented 2 years ago

Can you try to follow this ox-hugo Quick Start guide and see if the module setup instructions in there work for you?

https://ox-hugo.scripter.co/doc/quick-start/

kaushalmodi commented 2 years ago

I'll investigate in some time on how to fetch the external libs via hugo mod, but it's not highest on my priority list.

If you figure it out first, please do open a PR!

Thanks. :)

Robin-Wils commented 2 years ago

I think my own theme has to be a module for that as well or something. Nothing seems to work. hugo mod init was executed. Modules and themes which aren't imported by modules don't seem to work well together.

I think I figured out how to fetch the external libs, in the config.toml of my theme, but this component doesn't get imported somehow, so didn't really test it fully. Branch: https://gitlab.com/RobinWils/robinwils.com/-/tree/update-to-latest-hugo-search-fuse-js

kaushalmodi commented 2 years ago

Recursive module fetching does work (I am doing that for my main site), but I agree that getting hugo mod to work with a complicated setup is time consuming in the beginning.

Robin-Wils commented 2 years ago

I think I am getting somewhere. It does seem to run now locally. Just need some time to get it working.

Robin-Wils commented 2 years ago

Yeah, can't get it working somehow.