Skip to content

Commit

Permalink
Fixed acknowledged rules (#1679)
Browse files Browse the repository at this point in the history
* fixed path

* refactor

* added condition

* clean up
  • Loading branch information
babakamyljanovssw authored Feb 7, 2025
1 parent 9f63a44 commit 539d3f1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/pages/user/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const UserRules = ({ data, location }) => {
extractedFiles.push({
file: {
node: {
path: path.path.replace('rule.md', ''),
path: getRulePath(path.path),
lastUpdated: updatedTime,
},
},
Expand All @@ -202,6 +202,19 @@ const UserRules = ({ data, location }) => {
return extractedFiles;
};

const getRulePath = (path) => {
const lastSlashIndex = path.lastIndexOf('/');
if (
path.includes('.md') &&
!path.includes('categories') &&
lastSlashIndex !== -1
) {
return path.substring(0, lastSlashIndex + 1);
} else {
return path;
}
};

const filterUniqueRules = (extractedFiles) => {
const filteredRules = extractedFiles
.map((r) => {
Expand Down

0 comments on commit 539d3f1

Please sign in to comment.