aboutsummaryrefslogtreecommitdiffstats
path: root/internal/store/menu.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/store/menu.go')
-rw-r--r--internal/store/menu.go42
1 files changed, 0 insertions, 42 deletions
diff --git a/internal/store/menu.go b/internal/store/menu.go
index cedb7ad..e2314af 100644
--- a/internal/store/menu.go
+++ b/internal/store/menu.go
@@ -76,45 +76,3 @@ func (bs *BlogStore) SetPageInMenu(ctx context.Context, pageID int64, on bool) e
_, err := bs.db.Exec(ctx, `DELETE FROM menu_items WHERE page_id=$1`, pageID)
return err
}
-
-// AddMenuLink appends a custom link to the menu.
-func (bs *BlogStore) AddMenuLink(ctx context.Context, label, url string) error {
- _, err := bs.db.Exec(ctx, `INSERT INTO menu_items (label, url, sort_order)
- VALUES ($1,$2,(SELECT coalesce(max(sort_order),-1)+1 FROM menu_items))`, label, url)
- return err
-}
-
-func (bs *BlogStore) DeleteMenuItem(ctx context.Context, id int64) error {
- _, err := bs.db.Exec(ctx, `DELETE FROM menu_items WHERE id=$1`, id)
- return err
-}
-
-// MoveMenuItem swaps sort_order with the neighbouring entry (dir = -1 up, +1 down).
-func (bs *BlogStore) MoveMenuItem(ctx context.Context, id int64, dir int) error {
- items, err := bs.ListMenu(ctx)
- if err != nil {
- return err
- }
- idx := -1
- for i := range items {
- if items[i].ID == id {
- idx = i
- }
- }
- j := idx + dir
- if idx < 0 || j < 0 || j >= len(items) {
- return nil
- }
- items[idx], items[j] = items[j], items[idx]
- tx, err := bs.db.Begin(ctx)
- if err != nil {
- return err
- }
- defer tx.Rollback(ctx)
- for i, m := range items { // renumber everything; keeps orders dense
- if _, err := tx.Exec(ctx, `UPDATE menu_items SET sort_order=$2 WHERE id=$1`, m.ID, i); err != nil {
- return err
- }
- }
- return tx.Commit(ctx)
-}