Skip to content

Commit

Permalink
update logo project (#118)
Browse files Browse the repository at this point in the history
Co-authored-by: Huy Vo <huyvo@var-meta.com>
  • Loading branch information
hiimdev and Huy Vo authored Sep 20, 2024
1 parent c9ae1c3 commit edc11aa
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.
13 changes: 6 additions & 7 deletions apps/server/src/creator/creatorSubCategory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,23 @@ export async function creatorSubCategory(subPath: string) {
const parentPath = getParentPath(subPath)

try {
const dataString = await fsWrapper.readFile(`${parentPath}/category.json`)
const dataString = await fsWrapper.readFile(`${parentPath}category.json`)
const data: CategoryJSON = JSON.parse(dataString)
const cat = await connection
.getRepository(Categories)
.findOneBy({ name: data?.name })

const tmp = data.sub_categories.filter(
const tmp = data.sub_categories.find(
(entity) => (entity.pathname === subPathName),
)
if (tmp.length == 0) {
if (!tmp) {
console.log('This pull request is not valid')
}

const detail = tmp[0] // this is the detail of the category
const category = new Categories()
category.name = detail.name
category.description = detail.description
category.parentId = cat.parentId
category.name = tmp.name
category.description = tmp.description
category.parentId = cat.id

const created = await connection.getRepository(Categories).save(category)

Expand Down
18 changes: 10 additions & 8 deletions apps/server/src/utils/getFileName.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
export function getFileName(path: string): string {
if (!path || path === '/') return '';

const sanitizedPath = path.endsWith('/') ? path.slice(0, -1) : path;

const array = sanitizedPath.split('/');
return array[array.length - 1] || '';
}
export function getFileName(path: string) {
if (path == '/') return ''
if (path[path.length - 1] !== '/') {
const array = path.split('/')
return array[array.length - 1]
} else {
const array = path.split('/')
return array[array.length - 2]
}
}
19 changes: 8 additions & 11 deletions apps/server/src/utils/getParentPath.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
export function getParentPath(path: string): string {
if (!path || path === '/') {
console.log('sub path error');
return '';
export function getParentPath(path: string) {
let array = path.split('/')
if (array.length == 0) {
console.log('sub path error')
}

const array = path.split('/').filter(Boolean);
if (array.length === 0) {
console.log('sub path error');
return '';
let dataReturn = ''
for (let i = 0; i < array.length - 1; i++) {
dataReturn += `${array[i]}/`
}

const parentPath = array.slice(0, -1).join('/');
return parentPath ? `/${parentPath}` : '/';
return dataReturn
}
3 changes: 2 additions & 1 deletion projects/UserTools/category.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"status": "active",
"tags": [
"User Tools",
"Ecosystem"
"Ecosystem",
"Education"
],
"sub_categories": [
{
Expand Down

0 comments on commit edc11aa

Please sign in to comment.