Hello everyone,
I want to build a small indexer with bleve to index and search content in my hugosite. That’s work note mainly and I can’t use external service and elasticsearch take a lot of resource.
I want to build a small indexer with bleve and I need to parse my site. I’m mainly inspired with the code of fts5index (GitHub - fazalmajid/fts5index: SQLite FTS5-based search engine for Hugo pages) but the hugolib have change a lot since.
Have you an example of code for read all page of a designated hugosite or link to webpage with example ?
I wrote this but that don’t walk through pages
osFs := hugofs.Os
config, err := allconfig.LoadConfig(allconfig.ConfigSourceDescriptor{
Fs: osFs,
Filename: "config.toml",
ConfigDir: hugoPath,
Environment: "development",
})
if err != nil {
fmt.Println(err)
os.Exit(1)
}
base := config.GetFirstLanguageConfig().BaseConfig()
base.WorkingDir = hugoPath
fmt.Println(base.WorkingDir)
// Config loaded
fs := hugofs.NewFrom(osFs, base)
sites, err := hugolib.NewHugoSites(deps.DepsCfg{
Fs: fs,
Configs: config,
})
err = sites.Build(hugolib.BuildCfg{SkipRender: true})
if err != nil {
log.Fatal("Could not render site:", err)
}
fmt.Println(sites.Site.Title())
if sites != nil && (sites.Pages() != nil) {
for _, p := range sites.Pages() {
if p != nil {
fmt.Println(p.Description())
}
}
}
thanks for your help.
Best regards