Skip to content

Commit

Permalink
chore: refactored sitemap generation
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushSehrawat committed Dec 6, 2023
1 parent 75b02b9 commit 82a3792
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 27 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"postcss-load-config": "^4.0.1",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.1",
"super-sitemap": "^0.14.11",
"svelte": "^4.2.8",
"svelte-check": "^3.6.2",
"tailwindcss": "^3.3.5",
Expand Down
155 changes: 155 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 16 additions & 25 deletions src/routes/(root)/sitemap.xml/+server.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
export async function GET() {
return new Response(
`
<?xml version="1.0" encoding="UTF-8" ?>
<urlset
xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="https://www.w3.org/1999/xhtml"
xmlns:mobile="https://www.google.com/schemas/sitemap-mobile/1.0"
xmlns:news="https://www.google.com/schemas/sitemap-news/0.9"
xmlns:image="https://www.google.com/schemas/sitemap-image/1.1"
xmlns:video="https://www.google.com/schemas/sitemap-video/1.1"
>
<!-- <url> elements go here -->
<url>
<loc>https://rdm.ayush.gg/</loc>
<lastmod>2023-11-18T18:48:09+00:00</lastmod>
</url>
// /src/routes/sitemap.xml/+server.ts
import * as sitemap from 'super-sitemap';
import type { RequestHandler } from '@sveltejs/kit';

</urlset>`.trim(),
{
headers: {
'Content-Type': 'application/xml'
}
}
);
}
export const GET: RequestHandler = async () => {
return await sitemap.response({
origin: 'https://rdm.ayush.gg',
excludePatterns: [
'^/api.*',
'^/sitemap.xml',
'^/site.webmanifest',
'^/app/torrents/.+',
'^/app/downloads/.+',
'^/app/scraper/.+'
]
});
};
24 changes: 22 additions & 2 deletions src/routes/app/settings/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<script lang="ts">
import { invalidateAll } from '$app/navigation';
import { toast } from 'svelte-sonner';
import { Loader2 } from 'lucide-svelte';
import { Loader2, MagnetIcon } from 'lucide-svelte';
import { formatDate, convertBytes } from '$lib/app/helpers';
import type { DownloadsResponse, TorrentsResponse } from '$lib/app/types';
import { Separator } from '$lib/components/ui/separator';
import { Input } from '$lib/components/ui/input';
import { Label } from '$lib/components/ui/label';
import { Button } from '$lib/components/ui/button';
export let data;
Expand Down Expand Up @@ -36,8 +39,14 @@
totalTorrentsSize: convertBytes(totalTorrentBytes)
};
}
let magnetUri = '';
</script>

<svelte:head>
<title>Settings | RDM</title>
</svelte:head>

<div class="flex flex-col gap-4 p-8 md:px-24 lg:px-32">
<h1 class="text-4xl font-semibold">Settings</h1>
{#await getUserData()}
Expand All @@ -53,7 +62,6 @@
<p class="text-muted-foreground text-sm">
Expires at {formatDate(data.data.expiration, 'short')}
</p>
<Separator />
</div>
{:catch error}
<p class="text-red-500 dark:text-red-400">{error.message}</p>
Expand All @@ -69,6 +77,18 @@
<div class="flex flex-col gap-2">
<p>Total downloads size: <span class="font-semibold">{totalDownloadsSize}</span></p>
<p>Total torrents size: <span class="font-semibold">{totalTorrentsSize}</span></p>
<Separator />
</div>
{/await}

<div class="flex flex-col w-full md:max-w-2xl gap-2">
<div class="flex flex-wrap gap-2 items-center">
<Label class="text-xl" for="magnet">Add Magnet URI (In Progress)</Label>
<MagnetIcon class="w-5 h-5" />
</div>
<Input disabled bind:value={magnetUri} type="text" id="magnet" placeholder="magnet:?xt=urn:btih:....." />
<Button disabled on:click={() => {}} type="button" class="w-full md:max-w-max" variant="outline">
Add
</Button>
</div>
</div>
Loading

0 comments on commit 82a3792

Please sign in to comment.