diff --git a/frontend/src/component/p-navigation.vue b/frontend/src/component/p-navigation.vue index 782e251eb..808b5f182 100644 --- a/frontend/src/component/p-navigation.vue +++ b/frontend/src/component/p-navigation.vue @@ -90,7 +90,7 @@ + :key="index" :to="{ name: 'albums_view', params: { id: album.ID, slug: album.AlbumSlug } }"> {{ album.AlbumName }} Untitled diff --git a/frontend/src/pages/albums.vue b/frontend/src/pages/albums.vue index af062adb4..f0405f876 100644 --- a/frontend/src/pages/albums.vue +++ b/frontend/src/pages/albums.vue @@ -156,7 +156,7 @@ }, openAlbum(index) { const album = this.results[index]; - this.$router.push({name: "albums_view", params: {id: album.ID}}); + this.$router.push({name: "albums_view", params: {id: album.ID, slug: album.AlbumSlug}}); }, loadMore() { if (this.scrollDisabled) return; diff --git a/frontend/src/routes.js b/frontend/src/routes.js index bd8e3e3be..0ff3a5284 100644 --- a/frontend/src/routes.js +++ b/frontend/src/routes.js @@ -37,7 +37,7 @@ export default [ }, { name: "albums_view", - path: "/albums/:id", + path: "/albums/:id/:slug", component: AlbumsView, meta: {area: "View Album"}, }, diff --git a/internal/api/albums.go b/internal/api/albums.go index 4e3cad20f..f314c8d29 100644 --- a/internal/api/albums.go +++ b/internal/api/albums.go @@ -98,7 +98,7 @@ func UpdateAlbum(router *gin.RouterGroup, conf *config.Config) { return } - m.AlbumName = params.AlbumName + m.Rename(params.AlbumName) conf.Db().Save(&m) event.Publish("config.updated", event.Data(conf.ClientConfig())) diff --git a/internal/models/album.go b/internal/models/album.go index 5735d4319..74d1b8cc6 100644 --- a/internal/models/album.go +++ b/internal/models/album.go @@ -45,3 +45,8 @@ func NewAlbum(albumName string) *Album { return result } + +func (m *Album) Rename(albumName string) { + m.AlbumName = strings.TrimSpace(albumName) + m.AlbumSlug = slug.Make(m.AlbumName) +}