fix(plugins/adr): replace url record by the path

Signed-off-by: Andy Ladjadj <andy.ladjadj@gmail.com>
This commit is contained in:
Andy Ladjadj
2023-03-15 09:46:09 +01:00
committed by Andy Ladjadj
parent f66fb122ff
commit 668b5733b1
2 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -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
@@ -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}`}
>
<ListItemText
primary={adr.title ?? adr?.name.replace(/\.md$/, '')}
@@ -175,7 +175,7 @@ export const EntityAdrContent = (props: {
}, [entity, scmIntegrations]);
const selectedAdr =
adrList.find(adr => 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);