-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
110 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
import { latestFeaturedPost } from "@/lib/blog"; | ||
import BlogPostPill from "./BlogPostPill.astro"; | ||
const post = await latestFeaturedPost(Astro.url); | ||
--- | ||
|
||
{post && <BlogPostPill {post} />} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
import type { ProductData } from "@/lib/products"; | ||
interface Props { | ||
product: ProductData; | ||
} | ||
const { product } = Astro.props; | ||
--- | ||
|
||
<div class="flex items-center justify-end gap-2"> | ||
{product.id === "cheerpj3" && <div>Preview</div>} | ||
|
||
<label for="version-switcher" class="sr-only">Version</label> | ||
<select | ||
class="px-2 py-1 rounded bg-stone-950 text-stone-400 font-medium" | ||
id="version-switcher" | ||
> | ||
<option value="cheerpj3" selected={product.id === "cheerpj3"}> v3</option> | ||
<option value="cheerpj2" selected={product.id === "cheerpj2"}> v2</option> | ||
</select> | ||
</div> | ||
|
||
<script> | ||
const select = document.getElementById( | ||
"version-switcher", | ||
) as HTMLSelectElement; | ||
select.addEventListener("change", async () => { | ||
let href = location.pathname.replace(/\/cheerpj\d/, `/${select.value}`); | ||
|
||
// If the page doesn't exist, redirect to the homepage | ||
const req = await fetch(href, { method: "HEAD" }); | ||
if (req.status === 404) { | ||
href = `/${select.value}`; | ||
} | ||
|
||
location.href = href; | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters