diff options
| -rw-r--r-- | internal/mobius/threaded_news.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/mobius/threaded_news.go b/internal/mobius/threaded_news.go index f785bdf..eae2349 100644 --- a/internal/mobius/threaded_news.go +++ b/internal/mobius/threaded_news.go @@ -135,10 +135,18 @@ func (n *ThreadedNewsYAML) PostArticle(newsPath []string, parentArticleID uint32 } cats := n.getCatByPath(newsPath[:len(newsPath)-1]) + if cats == nil { + return fmt.Errorf("parent category path does not exist") + } catName := newsPath[len(newsPath)-1] cat := cats[catName] + // Initialize Articles map if nil (e.g., from old YAML files) + if cat.Articles == nil { + cat.Articles = make(map[uint32]*hotline.NewsArtData) + } + var keys []int for k := range cat.Articles { keys = append(keys, int(k)) |