Skip to content

Commit

Permalink
refactor: Remove unused code and clean up imports in category page co…
Browse files Browse the repository at this point in the history
…mponents
  • Loading branch information
SivaramPg committed Dec 21, 2024
1 parent 3ac0bc0 commit 7f8d0d2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
46 changes: 23 additions & 23 deletions src/app/[category]/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fsPromises, { readFile } from "node:fs/promises"
import { readFile } from "node:fs/promises"

import path from "node:path"
import ApiEndpointElement from "@/components/ApiEndpointElement"
Expand All @@ -9,31 +9,31 @@ import { notFound } from "next/navigation"

export const dynamic = "force-static"

export async function generateStaticParams() {
const slugs: { category: string; slug: string }[] = []
// export async function generateStaticParams() {
// const slugs: { category: string; slug: string }[] = []

const rawCategories = await fsPromises.readdir("public/api/", {
withFileTypes: true,
recursive: true,
})
for (const category of rawCategories) {
if (
category.isFile() &&
!["all.json", ".DS_Store", "root.json", "schema.json"].includes(
category.name,
)
) {
const categoryName = category.path.split("/").at(-1)
// const rawCategories = await fsPromises.readdir("public/api/", {
// withFileTypes: true,
// recursive: true,
// })
// for (const category of rawCategories) {
// if (
// category.isFile() &&
// !["all.json", ".DS_Store", "root.json", "schema.json"].includes(
// category.name,
// )
// ) {
// const categoryName = category.path.split("/").at(-1)

slugs.push({
category: categoryName ?? "",
slug: category.name.split(".")[0],
})
}
}
// slugs.push({
// category: categoryName ?? "",
// slug: category.name.split(".")[0],
// })
// }
// }

return slugs
}
// return slugs
// }

async function getCategorySlugJson(category: string, slug: string) {
try {
Expand Down
26 changes: 13 additions & 13 deletions src/app/[category]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fsPromises, { readFile } from "node:fs/promises"
import { readFile } from "node:fs/promises"

import { cn } from "@/utils/cn"

Expand All @@ -14,21 +14,21 @@ import { notFound } from "next/navigation"

export const dynamic = "force-static"

export async function generateStaticParams() {
const categories: { category: string }[] = []
// export async function generateStaticParams() {
// const categories: { category: string }[] = []

const rawCategories = await fsPromises.readdir("public/api", {
withFileTypes: true,
})
// const rawCategories = await fsPromises.readdir("public/api", {
// withFileTypes: true,
// })

for (const category of rawCategories) {
if (category.isDirectory()) {
categories.push({ category: category.name })
}
}
// for (const category of rawCategories) {
// if (category.isDirectory()) {
// categories.push({ category: category.name })
// }
// }

return categories
}
// return categories
// }

async function getCategoryAllJson(category: string) {
try {
Expand Down

0 comments on commit 7f8d0d2

Please sign in to comment.