Skip to content

Commit

Permalink
fix: articles folder used as language key if a root path is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkobrombin committed Feb 11, 2024
1 parent d50d5e9 commit 96251ee
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions core/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,8 @@ func getRepoArticles(repo structs.Repo) (map[string]structs.Article, error) {
lang = "en"
}
} else {
lang = strings.Split(articlePath, string(filepath.Separator))[2]
if lang == repo.RootPath {
lang = strings.Split(articlePath, string(filepath.Separator))[3]
}
furtherPath := strings.TrimPrefix(articlePath, filepath.Join(repo.Path, repo.RootPath))
lang = strings.Split(furtherPath, string(filepath.Separator))[1]
}

if _, ok := tmpArticleCacheGrouped[lang]; !ok {
Expand Down Expand Up @@ -325,7 +323,8 @@ func loadArticle(repo structs.Repo, path string) (structs.Article, error) {
lang = "en"
}
} else {
lang = strings.Split(path, string(filepath.Separator))[3]
furtherPath := strings.TrimPrefix(path, filepath.Join(repo.Path, repo.RootPath))
lang = strings.Split(furtherPath, string(filepath.Separator))[1]
}

article := structs.Article{
Expand Down

0 comments on commit 96251ee

Please sign in to comment.