From 668b5733b15715fdfc030d501be7a5f4d9b56655 Mon Sep 17 00:00:00 2001 From: Andy Ladjadj Date: Wed, 15 Mar 2023 09:46:09 +0100 Subject: [PATCH] fix(plugins/adr): replace url record by the path Signed-off-by: Andy Ladjadj --- plugins/adr-common/src/index.ts | 2 +- .../components/EntityAdrContent/EntityAdrContent.tsx | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/adr-common/src/index.ts b/plugins/adr-common/src/index.ts index c3a048d9d1..25b61d5aa4 100644 --- a/plugins/adr-common/src/index.ts +++ b/plugins/adr-common/src/index.ts @@ -77,7 +77,7 @@ export type AdrFilePathFilterFn = (path: string) => boolean; * @public */ export const madrFilePathFilter: AdrFilePathFilterFn = (path: string) => - /^\d{4}-.+\.md$/.test(path); + /^(?>.+\/)?\d{4}-.+\.md$/.test(path); /** * ADR indexable document interface diff --git a/plugins/adr/src/components/EntityAdrContent/EntityAdrContent.tsx b/plugins/adr/src/components/EntityAdrContent/EntityAdrContent.tsx index 846678f718..1567306f12 100644 --- a/plugins/adr/src/components/EntityAdrContent/EntityAdrContent.tsx +++ b/plugins/adr/src/components/EntityAdrContent/EntityAdrContent.tsx @@ -122,7 +122,7 @@ const AdrListContainer = (props: { component={Link} key={idx} selected={selectedAdr === adr.path} - to={`${rootLink()}?record=${adr.name}`} + to={`${rootLink()}?record=${adr.path}`} > adr.name === searchParams.get('record'))?.path ?? ''; + adrList.find(adr => adr.path === searchParams.get('record'))?.path ?? ''; const adrSubDirectoryFunc = (adr: AdrFileInfo) => { return adr.path.split('/').slice(0, -1).join('/'); @@ -183,7 +183,7 @@ export const EntityAdrContent = (props: { useEffect(() => { if (adrList.length && !selectedAdr) { - searchParams.set('record', adrList[0].name); + searchParams.set('record', adrList[0].path); setSearchParams(searchParams, { replace: true }); } }); @@ -197,8 +197,8 @@ export const EntityAdrContent = (props: { (item: AdrFileInfo) => item.type === 'file' && (filePathFilterFn - ? filePathFilterFn(item.name) - : madrFilePathFilter(item.name)), + ? filePathFilterFn(item.path) + : madrFilePathFilter(item.path)), ); setAdrList(adrs);