enzostvs HF Staff commited on
Commit
066d2e7
·
1 Parent(s): a8cda3d

inject badge only while first creation

Browse files
app/api/ask/route.ts CHANGED
@@ -546,7 +546,7 @@ export async function PUT(request: NextRequest) {
546
  } else if (page.path.endsWith(".json")) {
547
  mimeType = "application/json";
548
  }
549
- const content = (mimeType === "text/html" && isIndexPage(page.path))
550
  ? injectDeepSiteBadge(page.html)
551
  : page.html;
552
  const file = new File([content], page.path, { type: mimeType });
 
546
  } else if (page.path.endsWith(".json")) {
547
  mimeType = "application/json";
548
  }
549
+ const content = (mimeType === "text/html" && isIndexPage(page.path)) && isNew
550
  ? injectDeepSiteBadge(page.html)
551
  : page.html;
552
  const file = new File([content], page.path, { type: mimeType });
app/api/me/projects/[namespace]/[repoId]/save/route.ts CHANGED
@@ -3,7 +3,6 @@ import { uploadFiles } from "@huggingface/hub";
3
 
4
  import { isAuthenticated } from "@/lib/auth";
5
  import { Page } from "@/types";
6
- import { injectDeepSiteBadge, isIndexPage } from "@/lib/inject-badge";
7
 
8
  export async function PUT(
9
  req: NextRequest,
@@ -38,11 +37,7 @@ export async function PUT(
38
  } else if (page.path.endsWith(".json")) {
39
  mimeType = "application/json";
40
  }
41
- // Inject the DeepSite badge script into index pages only (not components or other HTML files)
42
- const content = (mimeType === "text/html" && isIndexPage(page.path))
43
- ? injectDeepSiteBadge(page.html)
44
- : page.html;
45
- const file = new File([content], page.path, { type: mimeType });
46
  files.push(file);
47
  });
48
 
 
3
 
4
  import { isAuthenticated } from "@/lib/auth";
5
  import { Page } from "@/types";
 
6
 
7
  export async function PUT(
8
  req: NextRequest,
 
37
  } else if (page.path.endsWith(".json")) {
38
  mimeType = "application/json";
39
  }
40
+ const file = new File([page.html], page.path, { type: mimeType });
 
 
 
 
41
  files.push(file);
42
  });
43