From e2439aa7ca8eecfea306b39dea49ab70c337eaa1 Mon Sep 17 00:00:00 2001 From: Baba Kamyljanov Date: Tue, 4 Feb 2025 18:07:19 +0800 Subject: [PATCH 1/4] fixed path --- src/pages/user/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pages/user/index.js b/src/pages/user/index.js index 9b31acea4..4568cc6a8 100644 --- a/src/pages/user/index.js +++ b/src/pages/user/index.js @@ -191,7 +191,7 @@ const UserRules = ({ data, location }) => { extractedFiles.push({ file: { node: { - path: path.path.replace('rule.md', ''), + path: getRulePath(path.path), lastUpdated: updatedTime, }, }, @@ -202,6 +202,15 @@ const UserRules = ({ data, location }) => { return extractedFiles; }; + function getRulePath(path) { + const lastSlashIndex = path.lastIndexOf('/'); + if (!path.includes('categories') && path.lastIndexOf('/') !== -1) { + return path.substring(0, lastSlashIndex + 1); + } else { + return path; + } + } + const filterUniqueRules = (extractedFiles) => { const filteredRules = extractedFiles .map((r) => { From 29468ce22422587a067b2e585e2ef9303b815cbc Mon Sep 17 00:00:00 2001 From: Baba Kamyljanov Date: Tue, 4 Feb 2025 18:08:38 +0800 Subject: [PATCH 2/4] refactor --- src/pages/user/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/user/index.js b/src/pages/user/index.js index 4568cc6a8..55166979f 100644 --- a/src/pages/user/index.js +++ b/src/pages/user/index.js @@ -202,14 +202,14 @@ const UserRules = ({ data, location }) => { return extractedFiles; }; - function getRulePath(path) { + const getRulePath = (path) => { const lastSlashIndex = path.lastIndexOf('/'); if (!path.includes('categories') && path.lastIndexOf('/') !== -1) { return path.substring(0, lastSlashIndex + 1); } else { return path; } - } + }; const filterUniqueRules = (extractedFiles) => { const filteredRules = extractedFiles From 35a187b60a760f76d7d6acfeff67c6e790bd848f Mon Sep 17 00:00:00 2001 From: Baba Kamyljanov Date: Wed, 5 Feb 2025 09:59:13 +0800 Subject: [PATCH 3/4] added condition --- src/pages/user/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/user/index.js b/src/pages/user/index.js index 55166979f..077894fea 100644 --- a/src/pages/user/index.js +++ b/src/pages/user/index.js @@ -204,7 +204,11 @@ const UserRules = ({ data, location }) => { const getRulePath = (path) => { const lastSlashIndex = path.lastIndexOf('/'); - if (!path.includes('categories') && path.lastIndexOf('/') !== -1) { + if ( + path.includes('.md') && + !path.includes('categories') && + path.lastIndexOf('/') !== -1 + ) { return path.substring(0, lastSlashIndex + 1); } else { return path; From 3fd540c38637554c114c72ee0e8b9e565854d831 Mon Sep 17 00:00:00 2001 From: Baba Kamyljanov Date: Thu, 6 Feb 2025 08:47:51 +0800 Subject: [PATCH 4/4] clean up --- src/pages/user/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/user/index.js b/src/pages/user/index.js index 077894fea..7dcae7fb0 100644 --- a/src/pages/user/index.js +++ b/src/pages/user/index.js @@ -207,7 +207,7 @@ const UserRules = ({ data, location }) => { if ( path.includes('.md') && !path.includes('categories') && - path.lastIndexOf('/') !== -1 + lastSlashIndex !== -1 ) { return path.substring(0, lastSlashIndex + 1); } else {