Skip to content

Commit

Permalink
Refactor badge URL handling and update documentation links
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorKowalczyk committed Dec 13, 2024
1 parent af1d156 commit 6a10538
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
8 changes: 6 additions & 2 deletions astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import preact from "@astrojs/preact";
import tailwind from "@astrojs/tailwind";
import deno from "@deno/astro-adapter";
import { defineConfig } from "astro/config";
import compressor from "astro-compressor";
import compress from "astro-compressor";

// https://astro.build/config
export default defineConfig({
output: "server",
site: "https://github-views.deno.dev",
redirects: {
"/github": "https://github.com/igorkowalczyk/views",
"/docs": "https://github.com/IgorKowalczyk/github-views?tab=readme-ov-file#-basic-usage",
},
adapter: deno(),
integrations: [tailwind(), preact(), compressor()],
integrations: [tailwind(), preact(), compress()],
});
12 changes: 6 additions & 6 deletions src/components/BadgePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ export default function BadgePreview({ defaultUrl }: { defaultUrl: string | unde
<h3 class="mb-1 font-medium text-neutral-400">Endpoint</h3>
<div class="relative flex flex-row gap-2 overflow-hidden rounded-lg bg-neutral-800 p-4">
<pre class="overflow-hidden whitespace-nowrap font-mono text-sm text-white">
{defaultUrl}/api/json/{debouncedInput || "example"}
{defaultUrl}api/json/{debouncedInput || "example"}
</pre>
<div class="absolute right-0 top-0 flex h-full items-center bg-gradient-to-r from-transparent via-neutral-800 to-neutral-800 p-2 pl-8">
<Button ref={buttonRef} variant="secondary" onClick={() => handleConfetti(`${defaultUrl}/api/json/${debouncedInput || "example"}`)} disabled={!input} className="px-2">
<Button ref={buttonRef} variant="secondary" onClick={() => handleConfetti(`${defaultUrl}api/json/${debouncedInput || "example"}`)} disabled={!input} className="px-2">
<CopyIcon />
</Button>
</div>
Expand Down Expand Up @@ -131,29 +131,29 @@ export default function BadgePreview({ defaultUrl }: { defaultUrl: string | unde
<span style="color:#DBEDFF;text-decoration:underline">Profile views</span>
<span style="color:#E1E4E8">](</span>
<span style="color:#E1E4E8;text-decoration:underline">
{defaultUrl}/api/badge/{debouncedInput || "example"}?style={style}
{defaultUrl}api/badge/{debouncedInput || "example"}?style={style}
</span>
<span style="color:#E1E4E8">)</span>
</span>
</code>
</pre>
<div class="absolute right-0 top-0 flex h-full items-center bg-gradient-to-r from-transparent via-neutral-800 to-neutral-800 p-2 pl-8">
<Button ref={buttonRef} variant="secondary" onClick={() => handleConfetti(`![Profile views](${defaultUrl}/api/badge/${debouncedInput || "example"}?style=${style})`)} disabled={!input} className="px-2">
<Button ref={buttonRef} variant="secondary" onClick={() => handleConfetti(`![Profile views](${defaultUrl}api/badge/${debouncedInput || "example"}?style=${style})`)} disabled={!input} className="px-2">
<CopyIcon />
</Button>
</div>
</div>

<h3 class="mt-6 font-medium text-neutral-400">Preview</h3>
<div class="my-1 rounded-lg bg-neutral-800 p-4">
<img src={`${defaultUrl}/api/badge/${debouncedInput || "example"}?style=${style}&display=true`} alt="Profile views" class="h-6" />
<img src={`${defaultUrl}api/badge/${debouncedInput || "example"}?style=${style}&display=true`} alt="Profile views" class="h-6" />
</div>
</>
)}

<p class="my-4 text-sm font-medium text-neutral-400">
Looking for more styles?{" "}
<a href="https://github.com/IgorKowalczyk/github-views?tab=readme-ov-file#%EF%B8%8F-available-styles" target="_blank" class="underline">
<a href="/docs" target="_blank" class="underline">
Check out the documentation
</a>
.
Expand Down
7 changes: 3 additions & 4 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
import astroConfig from "astro.config";
import BadgePreview from "@/components/BadgePreview";
import { Button } from "@/components/Button";
import Description from "@/components/Description.astro";
Expand All @@ -13,10 +12,10 @@ import Layout from "@/layouts/Layout.astro";
<Header id="main">@igorkowalczyk/profile-views</Header>
<Description>Create your own badge that will count views anywhere you want!</Description>
<div class="mt-4 flex items-center justify-center gap-4">
<a href={"https://github.com/IgorKowalczyk/github-views?tab=readme-ov-file#%EF%B8%8F-available-styles"}>
<a href="/docs">
<Button variant="primary">Documentation</Button>
</a>
<a href="https://github.com/igorkowalczyk/views" target="_blank">
<a href="/github" target="_blank">
<Button variant="secondary">Github</Button>
</a>
</div>
Expand All @@ -27,6 +26,6 @@ import Layout from "@/layouts/Layout.astro";
</section>

<section class="border-x border-b border-neutral-800 px-6" id="preview">
<BadgePreview client:visible defaultUrl={astroConfig.site} />
<BadgePreview client:visible defaultUrl={Astro.site?.toString()} />
</section>
</Layout>

0 comments on commit 6a10538

Please sign in to comment.