From 0c99509ebf7b36098b386fccaf8e62a2c1d9b0f2 Mon Sep 17 00:00:00 2001 From: jendiamond Date: Fri, 18 Oct 2024 13:15:57 -0700 Subject: [PATCH 01/11] redirect --- public/_redirects | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/public/_redirects b/public/_redirects index 65f60d7b3..94b6a5983 100644 --- a/public/_redirects +++ b/public/_redirects @@ -26,6 +26,20 @@ /about/programs/library-special-collections-lsc-research-fellowships-2023 /about/programs/library-special-collections-lsc-research-fellowships /about/staff/chen-gao-%E9%AB%98%E6%99%A8 /about/staff/chen-gao/ /about/staff/hui-li-%E6%9D%8E%E6%85%A7 /about/staff/hui-li/ + + + + +/about/staff/?q=&filters={"subjectLibrarian.keyword":"yes"} /about/staff/?q=&filters=subjectLibrarian.keyword:(yes) + +/about/staff/?q=&filters={"subjectLibrarian.keyword":"yes"} + +/about/staff?q=&filters=subjectLibrarian.keyword:(yes)&lastNameLetter=M + + + + + /about/student-positions /about/student-opportunities /about/policies/report-problematic-content-and-description-in-uclas-library-collections-and-archives https://ucla.libwizard.com/id/38f45c482a5fcb0b715a7e9e3ddee8b2 /access-privileges/library-cards /help/services-resources/library-cards From dcd86d441b3637ba14f009aedb7705f5d1a9fbee Mon Sep 17 00:00:00 2001 From: jendiamond Date: Fri, 18 Oct 2024 13:18:56 -0700 Subject: [PATCH 02/11] redirect --- public/_redirects | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/public/_redirects b/public/_redirects index 94b6a5983..b4f06d0f7 100644 --- a/public/_redirects +++ b/public/_redirects @@ -26,20 +26,7 @@ /about/programs/library-special-collections-lsc-research-fellowships-2023 /about/programs/library-special-collections-lsc-research-fellowships /about/staff/chen-gao-%E9%AB%98%E6%99%A8 /about/staff/chen-gao/ /about/staff/hui-li-%E6%9D%8E%E6%85%A7 /about/staff/hui-li/ - - - - /about/staff/?q=&filters={"subjectLibrarian.keyword":"yes"} /about/staff/?q=&filters=subjectLibrarian.keyword:(yes) - -/about/staff/?q=&filters={"subjectLibrarian.keyword":"yes"} - -/about/staff?q=&filters=subjectLibrarian.keyword:(yes)&lastNameLetter=M - - - - - /about/student-positions /about/student-opportunities /about/policies/report-problematic-content-and-description-in-uclas-library-collections-and-archives https://ucla.libwizard.com/id/38f45c482a5fcb0b715a7e9e3ddee8b2 /access-privileges/library-cards /help/services-resources/library-cards From 81af32afea3cb9b86c591e5963c642739b3bd4c8 Mon Sep 17 00:00:00 2001 From: jendiamond Date: Fri, 18 Oct 2024 14:35:20 -0700 Subject: [PATCH 03/11] add redirect to the nuxt config ts --- nuxt.config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/nuxt.config.ts b/nuxt.config.ts index 31346ad32..7c0083227 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -127,6 +127,7 @@ export default defineNuxtConfig({ routeRules: { '/impact/all': { redirect: '/about/reports' }, + '/about/staff/?q=&filters={%22subjectLibrarian.keyword%22:%22yes%22}': {redirect: '/about/staff/?q=&filters=subjectLibrarian.keyword:(yes)'}, }, /* From 5406bb8ae5772fe8d888f623c30f88199ff55854 Mon Sep 17 00:00:00 2001 From: jendiamond Date: Fri, 18 Oct 2024 14:37:22 -0700 Subject: [PATCH 04/11] linting --- nuxt.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index 7c0083227..7e2123c24 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -127,7 +127,7 @@ export default defineNuxtConfig({ routeRules: { '/impact/all': { redirect: '/about/reports' }, - '/about/staff/?q=&filters={%22subjectLibrarian.keyword%22:%22yes%22}': {redirect: '/about/staff/?q=&filters=subjectLibrarian.keyword:(yes)'}, + '/about/staff/?q=&filters={%22subjectLibrarian.keyword%22:%22yes%22}': { redirect: '/about/staff/?q=&filters=subjectLibrarian.keyword:(yes)' }, }, /* From f8081393502a3376e93f56f3e8b1dfcb86c2ac58 Mon Sep 17 00:00:00 2001 From: jendiamond Date: Fri, 18 Oct 2024 15:39:36 -0700 Subject: [PATCH 05/11] setup edge function in nuxt repo & add to netlify toml --- netlify.toml | 6 +++++- netlify/edge-functions/redirect.js | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 netlify/edge-functions/redirect.js diff --git a/netlify.toml b/netlify.toml index e66a8446d..77ac6ec6f 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,3 +1,7 @@ [[edge_functions]] path = "/*" -function = "blockUserAgents" \ No newline at end of file +function = "blockUserAgents" + +[[edge_functions]] +function = "redirect" +path = "/about/staff" diff --git a/netlify/edge-functions/redirect.js b/netlify/edge-functions/redirect.js new file mode 100644 index 000000000..88708fb9d --- /dev/null +++ b/netlify/edge-functions/redirect.js @@ -0,0 +1,20 @@ +export default async (request, context) => { + const url = new URL(request.url); + const params = url.searchParams; + const filters = params.get('filters'); + + if (filters && filters === '{"subjectLibrarian.keyword":"yes"}') { + // Modify the query parameters + params.set('filters', 'subjectLibrarian.keyword:(yes)'); + + // Redirect to the new URL with the updated parameters + return new Response(null, { + status: 302, + headers: { + Location: `${url.pathname}?${params.toString()}` + } + }); + } + + return context.next(); +}; From 96c6b48982ce924a1f92a22a5c040ba5e6578ed4 Mon Sep 17 00:00:00 2001 From: jendiamond Date: Fri, 18 Oct 2024 15:44:43 -0700 Subject: [PATCH 06/11] update edge_functions netlify toml --- netlify.toml | 2 +- netlify/edge-functions/redirect.js | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/netlify.toml b/netlify.toml index 77ac6ec6f..60b0b49f6 100644 --- a/netlify.toml +++ b/netlify.toml @@ -3,5 +3,5 @@ path = "/*" function = "blockUserAgents" [[edge_functions]] -function = "redirect" path = "/about/staff" +function = "redirect" diff --git a/netlify/edge-functions/redirect.js b/netlify/edge-functions/redirect.js index 88708fb9d..e65c1ab7e 100644 --- a/netlify/edge-functions/redirect.js +++ b/netlify/edge-functions/redirect.js @@ -1,11 +1,11 @@ export default async (request, context) => { - const url = new URL(request.url); - const params = url.searchParams; - const filters = params.get('filters'); + const url = new URL(request.url) + const params = url.searchParams + const filters = params.get('filters') if (filters && filters === '{"subjectLibrarian.keyword":"yes"}') { // Modify the query parameters - params.set('filters', 'subjectLibrarian.keyword:(yes)'); + params.set('filters', 'subjectLibrarian.keyword:(yes)') // Redirect to the new URL with the updated parameters return new Response(null, { @@ -13,8 +13,8 @@ export default async (request, context) => { headers: { Location: `${url.pathname}?${params.toString()}` } - }); + }) } - return context.next(); -}; + return context.next() +} From 31e5176735bee0f110c1ec97131a4ccb21c7c1b9 Mon Sep 17 00:00:00 2001 From: jendiamond Date: Fri, 18 Oct 2024 15:49:40 -0700 Subject: [PATCH 07/11] add await to the redirect js --- netlify/edge-functions/redirect.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netlify/edge-functions/redirect.js b/netlify/edge-functions/redirect.js index e65c1ab7e..42bda19d5 100644 --- a/netlify/edge-functions/redirect.js +++ b/netlify/edge-functions/redirect.js @@ -1,7 +1,7 @@ export default async (request, context) => { - const url = new URL(request.url) - const params = url.searchParams - const filters = params.get('filters') + const url = await new URL(request.url) + const params = await url.searchParams + const filters = await params.get('filters') if (filters && filters === '{"subjectLibrarian.keyword":"yes"}') { // Modify the query parameters From b6d3eb8c5084ef3d3b0541c5bf63e8079c89b878 Mon Sep 17 00:00:00 2001 From: jendiamond Date: Thu, 24 Oct 2024 10:26:07 -0700 Subject: [PATCH 08/11] add middleware/redirect.global.js: to redirect --- middleware/redirect.global.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 middleware/redirect.global.js diff --git a/middleware/redirect.global.js b/middleware/redirect.global.js new file mode 100644 index 000000000..5b329cca9 --- /dev/null +++ b/middleware/redirect.global.js @@ -0,0 +1,15 @@ +export default defineNuxtRouteMiddleware((to) => { + const filters = to.query.filters; + + // Check if the filters parameter matches the condition + if (filters && filters === '{"subjectLibrarian.keyword":"yes"}') { + // Modify the query parameter + const newFilters = 'subjectLibrarian.keyword:(yes)'; + + // Construct the new query object + const newQuery = { ...to.query, filters: newFilters }; + + // Redirect to the new URL with updated query parameters + return navigateTo({ path: to.path, query: newQuery }); + } +}); From fa56dd7dcd4aa04c1e9045d27565efec997d5cf2 Mon Sep 17 00:00:00 2001 From: jendiamond Date: Thu, 24 Oct 2024 11:02:49 -0700 Subject: [PATCH 09/11] linting --- middleware/redirect.global.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/middleware/redirect.global.js b/middleware/redirect.global.js index 5b329cca9..b01f21cda 100644 --- a/middleware/redirect.global.js +++ b/middleware/redirect.global.js @@ -1,15 +1,15 @@ export default defineNuxtRouteMiddleware((to) => { - const filters = to.query.filters; + const filters = to.query.filters // Check if the filters parameter matches the condition if (filters && filters === '{"subjectLibrarian.keyword":"yes"}') { // Modify the query parameter - const newFilters = 'subjectLibrarian.keyword:(yes)'; + const newFilters = 'subjectLibrarian.keyword:(yes)' // Construct the new query object - const newQuery = { ...to.query, filters: newFilters }; + const newQuery = { ...to.query, filters: newFilters } // Redirect to the new URL with updated query parameters - return navigateTo({ path: to.path, query: newQuery }); + return navigateTo({ path: to.path, query: newQuery }) } -}); +}) From 893c2c0a7ad1e94c63efeaedba7e1f9e26474d83 Mon Sep 17 00:00:00 2001 From: jendiamond Date: Thu, 24 Oct 2024 12:03:44 -0700 Subject: [PATCH 10/11] delelte netlify.toml & edge-functions to redirect.js --- netlify.toml | 4 ---- netlify/edge-functions/redirect.js | 20 -------------------- 2 files changed, 24 deletions(-) delete mode 100644 netlify/edge-functions/redirect.js diff --git a/netlify.toml b/netlify.toml index 60b0b49f6..f40b32500 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,7 +1,3 @@ [[edge_functions]] path = "/*" function = "blockUserAgents" - -[[edge_functions]] -path = "/about/staff" -function = "redirect" diff --git a/netlify/edge-functions/redirect.js b/netlify/edge-functions/redirect.js deleted file mode 100644 index 42bda19d5..000000000 --- a/netlify/edge-functions/redirect.js +++ /dev/null @@ -1,20 +0,0 @@ -export default async (request, context) => { - const url = await new URL(request.url) - const params = await url.searchParams - const filters = await params.get('filters') - - if (filters && filters === '{"subjectLibrarian.keyword":"yes"}') { - // Modify the query parameters - params.set('filters', 'subjectLibrarian.keyword:(yes)') - - // Redirect to the new URL with the updated parameters - return new Response(null, { - status: 302, - headers: { - Location: `${url.pathname}?${params.toString()}` - } - }) - } - - return context.next() -} From db9ead06bbe3ac2369896b63a9d29e520ace67e4 Mon Sep 17 00:00:00 2001 From: jendiamond Date: Thu, 24 Oct 2024 12:19:35 -0700 Subject: [PATCH 11/11] delete the redirects in nuxt.config.ts & in _redirects --- nuxt.config.ts | 1 - public/_redirects | 1 - 2 files changed, 2 deletions(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index 7e2123c24..31346ad32 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -127,7 +127,6 @@ export default defineNuxtConfig({ routeRules: { '/impact/all': { redirect: '/about/reports' }, - '/about/staff/?q=&filters={%22subjectLibrarian.keyword%22:%22yes%22}': { redirect: '/about/staff/?q=&filters=subjectLibrarian.keyword:(yes)' }, }, /* diff --git a/public/_redirects b/public/_redirects index b4f06d0f7..65f60d7b3 100644 --- a/public/_redirects +++ b/public/_redirects @@ -26,7 +26,6 @@ /about/programs/library-special-collections-lsc-research-fellowships-2023 /about/programs/library-special-collections-lsc-research-fellowships /about/staff/chen-gao-%E9%AB%98%E6%99%A8 /about/staff/chen-gao/ /about/staff/hui-li-%E6%9D%8E%E6%85%A7 /about/staff/hui-li/ -/about/staff/?q=&filters={"subjectLibrarian.keyword":"yes"} /about/staff/?q=&filters=subjectLibrarian.keyword:(yes) /about/student-positions /about/student-opportunities /about/policies/report-problematic-content-and-description-in-uclas-library-collections-and-archives https://ucla.libwizard.com/id/38f45c482a5fcb0b715a7e9e3ddee8b2 /access-privileges/library-cards /help/services-resources/library-cards