This repository has been archived by the owner on Feb 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
154 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Build | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: pnpm/action-setup@v4 | ||
name: Install pnpm | ||
with: | ||
version: 9 | ||
run_install: false | ||
|
||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: "pnpm" | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Build | ||
run: | | ||
pnpm run prisma:update | ||
pnpm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { NextResponse } from "next/server"; | ||
import { prisma } from "@/app/lib/db/prisma"; | ||
import { StatusCodes } from "http-status-codes"; | ||
|
||
export async function GET( | ||
request: Request, | ||
{ params }: { params: { id: string } } | ||
) { | ||
try { | ||
let parents = await getParentTags(Number(params.id)); | ||
parents.reverse(); | ||
|
||
return NextResponse.json({ | ||
parents, | ||
}); | ||
} catch (error) { | ||
return NextResponse.json( | ||
{ error: "Error fetching tag" }, | ||
{ status: StatusCodes.INTERNAL_SERVER_ERROR } | ||
); | ||
} | ||
} | ||
|
||
async function getParentTags(id: number, parents: string[] = []) { | ||
const tag = await prisma.tag.findUnique({ | ||
where: { id }, | ||
include: { parent: true }, | ||
}); | ||
|
||
if (!tag || !tag.parent) { | ||
return parents; | ||
} | ||
|
||
const parentId = tag.parent.parentId; | ||
|
||
const pTag = await prisma.tag.findUnique({ | ||
where: { id: parentId }, | ||
include: { parent: true }, | ||
}); | ||
|
||
parents.push(pTag?.name as string); | ||
return getParentTags(parentId, parents); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"use client"; | ||
|
||
import { useState, useEffect } from "react"; | ||
import Explorer from "@/app/components/explorer"; | ||
import { Breadcrumbs, Link, Typography } from "@mui/material"; | ||
import { Tag } from "@/app/lib/db/types"; | ||
import { getTag } from "@/app/lib/tags"; | ||
|
||
export default function Page({ params }: { params: { tag: string } }) { | ||
const [tag, setTag] = useState<Tag | null>(null); | ||
const [parents, setParents] = useState<string[]>([]); | ||
|
||
useEffect(() => { | ||
updateTag(); | ||
}, []); | ||
|
||
const updateTag = async () => { | ||
const response = await fetch(`/api/tags/${params.tag}/parents`, { | ||
method: "GET", | ||
headers: { "Content-Type": "application/json" }, | ||
}); | ||
|
||
if (!response.ok) { | ||
return; | ||
} | ||
|
||
const data = await response.json(); | ||
setParents(data.parents); | ||
|
||
const tag = await getTag(Number(params.tag), false, false, false); | ||
setTag(tag); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Breadcrumbs> | ||
<Link underline="hover" color="inherit" href="/explorer"> | ||
Root | ||
</Link> | ||
{parents.map((p, i) => ( | ||
<Link | ||
key={i} | ||
underline="hover" | ||
color="inherit" | ||
href={`/explorer/${p}`} | ||
> | ||
{p} | ||
</Link> | ||
))} | ||
<Typography sx={{ color: "text.primary" }}>{tag?.name}</Typography> | ||
</Breadcrumbs> | ||
<Explorer tagId={Number(params.tag)} /> | ||
</div> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters