enzostvs HF staff commited on
Commit
ad36e9e
·
1 Parent(s): 62c9fe7

update sitemapo

Browse files
package-lock.json CHANGED
The diff for this file is too large to render. See raw diff
 
package.json CHANGED
@@ -43,7 +43,6 @@
43
  "dependencies": {
44
  "@aws-sdk/client-s3": "^3.490.0",
45
  "@huggingface/hub": "^0.12.3",
46
- "@huggingface/space-header": "^1.0.2",
47
  "@iconify/svelte": "^3.1.4",
48
  "@prisma/client": "^5.7.1",
49
  "@svelte-put/clickoutside": "^3.0.1",
@@ -59,6 +58,7 @@
59
  "node-cron": "^3.0.3",
60
  "node-fetch": "^3.3.2",
61
  "puppeteer": "^22.11.2",
62
- "svelte-infinite-scroll": "^2.0.1"
 
63
  }
64
  }
 
43
  "dependencies": {
44
  "@aws-sdk/client-s3": "^3.490.0",
45
  "@huggingface/hub": "^0.12.3",
 
46
  "@iconify/svelte": "^3.1.4",
47
  "@prisma/client": "^5.7.1",
48
  "@svelte-put/clickoutside": "^3.0.1",
 
58
  "node-cron": "^3.0.3",
59
  "node-fetch": "^3.3.2",
60
  "puppeteer": "^22.11.2",
61
+ "svelte-infinite-scroll": "^2.0.1",
62
+ "@huggingface/space-header": "/Users/enzo/Desktop/development/huggingface.js/packages/space-header"
63
  }
64
  }
src/routes/api/models/sitemap/+server.ts ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { json } from '@sveltejs/kit';
2
+ import prisma from '$lib/prisma';
3
+
4
+ /** @type {import('./$types').RequestHandler} */
5
+
6
+ export async function GET() {
7
+ const cards = await prisma.model.findMany({
8
+ where: {
9
+ isPublic: true,
10
+ },
11
+ select: {
12
+ id: true,
13
+ likes: true,
14
+ downloads: true,
15
+ likes7d: true,
16
+ image: true,
17
+ isPublic: true,
18
+ createdAt: true,
19
+ },
20
+ })
21
+
22
+ return json({
23
+ cards,
24
+ })
25
+ }
src/routes/sitemap.xml/+server.js CHANGED
@@ -1,4 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
  export async function GET() {
 
2
  return new Response(
3
  `
4
  <?xml version="1.0" encoding="UTF-8" ?>
@@ -10,6 +23,17 @@ export async function GET() {
10
  xmlns:image="https://www.google.com/schemas/sitemap-image/1.1"
11
  xmlns:video="https://www.google.com/schemas/sitemap-video/1.1"
12
  >
 
 
 
 
 
 
 
 
 
 
 
13
  <!-- <url> elements go here -->
14
  </urlset>`.trim(),
15
  {
 
1
+ const getAllModels = async () => {
2
+ const response = await fetch("http://localhost:5174/api/models/sitemap", {
3
+ method: "GET",
4
+ headers: {
5
+ "Content-Type": "application/json"
6
+ }
7
+ })
8
+ const models = await response.json()
9
+
10
+ return models.cards
11
+
12
+ };
13
  export async function GET() {
14
+ const models = await getAllModels()
15
  return new Response(
16
  `
17
  <?xml version="1.0" encoding="UTF-8" ?>
 
23
  xmlns:image="https://www.google.com/schemas/sitemap-image/1.1"
24
  xmlns:video="https://www.google.com/schemas/sitemap-video/1.1"
25
  >
26
+ ${models
27
+ .map(
28
+ (model) =>
29
+ `
30
+ <url>
31
+ <loc>https://lorastudio.co/models/${model.id}</loc>
32
+ <lastModified>${new Date(model.createdAt).toISOString()}</lastModified>
33
+ </url>
34
+ `
35
+ )
36
+ .join("")}
37
  <!-- <url> elements go here -->
38
  </urlset>`.trim(),
39
  {