From e424f3c270c99b0f5c20b8437237f4e4c4d7cb52 Mon Sep 17 00:00:00 2001 From: bach Date: Mon, 27 Feb 2023 18:25:03 +0100 Subject: [PATCH] redirecting /items/[UUID] to /texts/[TEXTID]/[UUID] #2057 --- src/router/index.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/router/index.js b/src/router/index.js index 8cdeaa1..c27cbd9 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,6 +1,8 @@ import Vue from 'vue' import Router from 'vue-router' +import { REST } from 'api/rest-axios' + import Home from 'pages/Home' // import Item from 'pages/Item' import ListCorpus from 'pages/ListCorpus' @@ -115,6 +117,29 @@ const routes = [ component: Bibliographie, props: true }, + { + name: 'items', + path: '/items/:uuid', + beforeEnter: async (to, from, next) => { + console.log('items before enter', from, to, next) + + let item = await REST.get(`${window.apipath}/items/` + to.params.uuid, {}) + .then(({ data }) => { + // console.log('corpus getEditionsList REST: author, data', author, data) + return data.content + }) + .catch((error) => { + console.warn('Issue with getEditionsList', error) + // Promise.reject(error) + }) + console.log('items : item', item) + // item.textid = 'gdpSauval1724' + // this named route does not replace the url + // next({ name: 'editiontext', params: { id: item.textid, textid: item.uuid }, replace: true }) + next({ path: `/texts/${item.textid}/${item.uuid}`, replace: true }) + }, + component: { render: () => null } + }, { name: 'notfound', path: '/404',