Jiseoup/showmycodePublic
EN|KO
  • Code
  • Commits
  • Pull Requests
← Back to list

feat: make file tree default expansion depth configurable via FILE_TREE_DEPTH env var

JiseoupJiseoup · Apr 13, 20260793d53

Files changed3+12 -1

Changed files

+12 -1 · 3

@@ -58,6 +58,7 @@ function TreeNodeItem({
selectedPath,
branch,
depth,
+ defaultOpenDepth,
}: {
node: TreeNode;
owner: string;
@@ -66,9 +67,10 @@ function TreeNodeItem({
selectedPath?: string;
branch: string;
depth: number;
+ defaultOpenDepth: number;
}) {
const [open, setOpen] = useState(
- depth < 1 || (selectedPath?.startsWith(node.path + "/") ?? false)
+ depth < defaultOpenDepth || (selectedPath?.startsWith(node.path + "/") ?? false)
);
if (node.type === "tree") {
@@ -99,6 +101,7 @@ function TreeNodeItem({
selectedPath={selectedPath}
branch={branch}
depth={depth + 1}
+ defaultOpenDepth={defaultOpenDepth}
/>
))}
</ul>
@@ -136,13 +139,15 @@ export function FileTree({
lang,
selectedPath,
branch,
+ defaultOpenDepth = 0,
}: {
items: GhTreeItem[];
owner: string;
repo: string;
lang: string;
selectedPath?: string;
branch: string;
+ defaultOpenDepth?: number;
}) {
const tree = buildTree(items);
@@ -158,6 +163,7 @@ export function FileTree({
selectedPath={selectedPath}
branch={branch}
depth={0}
+ defaultOpenDepth={defaultOpenDepth}
/>
))}
</ul>
@@ -15,6 +15,7 @@ type Props = {
export async function Sidebar({ owner, repo, lang, filesLabel, selectedPath, branches, branch }: Props) {
const { tree } = await getTree(owner, repo, branch);
+ const defaultOpenDepth = Number(process.env.FILE_TREE_DEPTH) || 0;
return (
<aside className="flex flex-col h-full overflow-hidden">
@@ -35,6 +36,7 @@ export async function Sidebar({ owner, repo, lang, filesLabel, selectedPath, bra
lang={lang}
selectedPath={selectedPath}
branch={branch}
+ defaultOpenDepth={defaultOpenDepth}
/>
</div>
</aside>
@@ -8,6 +8,9 @@ GITHUB_OWNER=
# 공개할 레포 이름 (쉼표로 구분)
GITHUB_REPOS=
+# File tree default expansion depth (0 = all collapsed, 1 = root expanded, etc.)
+FILE_TREE_DEPTH=0
+
# Access token for the share link (e.g. a long random string)
# Share URL: https://your-domain.com/?token=<SHARE_TOKEN>
# Leave empty to block all access.