Skip to content

Commit

Permalink
this should fix the url issues
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Mar 4, 2024
1 parent c1b4ddf commit dbcaf6c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
1 change: 1 addition & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import tailwind from "@astrojs/tailwind";
// https://astro.build/config
export default defineConfig({
site: 'https://globed.dev',
base: '/',
integrations: [tailwind()]
});
3 changes: 2 additions & 1 deletion src/components/Button.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
const { link, style, solidWidth } = Astro.props;
const url = link.startsWith('https') || link.startsWith('#') ? link : `${import.meta.env.BASE_URL}${link}`;
const urlBase = import.meta.env.BASE_URL.endsWith('/') ? import.meta.env.BASE_URL.slice(0, -1) : import.meta.env.BASE_URL;
const url = link.startsWith('https') || link.startsWith('#') ? link : `${urlBase}${link}`;
const classList = `${style} ${Astro.slots.has('post-icon') ? 'has-post-icon' : ''} ${solidWidth === 'true' ? 'is-solid-width' : ''}`;
---

Expand Down
3 changes: 2 additions & 1 deletion src/components/Link.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
const { href, style, noUnderline } = Astro.props;
const classList = `${style} ${noUnderline === 'true' ? 'no-link-underline' : ''}`;
const url = href.startsWith('https') || href.startsWith('#') ? href : `${import.meta.env.BASE_URL}${href}`;
const urlBase = import.meta.env.BASE_URL.endsWith('/') ? import.meta.env.BASE_URL.slice(0, -1) : import.meta.env.BASE_URL;
const url = href.startsWith('https') || href.startsWith('#') ? href : `${urlBase}${href}`;
---
<!-- this is to prevent any unintended whitespace appearing after the link --><a href={url} class={classList}><slot/></a><style>
a {
Expand Down
23 changes: 10 additions & 13 deletions src/components/Navbar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import discord from "../images/discord.svg?raw"
import github from "../images/github.svg?raw"
import kofi from "../images/kofi.svg?raw"
const base = import.meta.env.BASE_URL;
const urlBase = import.meta.env.BASE_URL.endsWith('/') ? import.meta.env.BASE_URL.slice(0, -1) : import.meta.env.BASE_URL;
---

<nav class="
Expand All @@ -20,16 +20,16 @@ const base = import.meta.env.BASE_URL;
">
<div class="grid sm:grid-cols-3 max-sm:grid-cols-2 justify-center items-center">
<div class="flex flex-row justify-start items-center gap-3">
<a class="home-button" href={base}>
<a class="home-button" href={`${urlBase}/`}>
<!-- <Image src={logo} alt="Globed logo" class="w-[24px] h-[24px]"/> -->
<GlobeIcon/>
<span class="font-head text-xl">Globed</span>
</a>
</div>
<div class="flex flex-row justify-center max-sm:hidden font-head text-lg">
<a href={base}>Home</a>
<a href={`${base}/install`}>Install</a>
<a href={`${base}/about`}>About</a>
<a href={`${urlBase}/`}>Home</a>
<a href={`${urlBase}/install`}>Install</a>
<a href={`${urlBase}/about`}>About</a>
</div>
<div class="flex flex-row justify-end">
<a href="https://ko-fi.com/globed">
Expand All @@ -50,22 +50,19 @@ const base = import.meta.env.BASE_URL;
</div>
</div>
<div id="rollover" class="flex flex-col px-4 font-head">
<a href={base}><span>Home</span></a>
<a href={`${base}/install`}><span>Install</span></a>
<a href={`${base}/about`}><span>About</span></a>
<a href={`${urlBase}/`}><span>Home</span></a>
<a href={`${urlBase}/install`}><span>Install</span></a>
<a href={`${urlBase}/about`}><span>About</span></a>
</div>
</nav>

<script define:vars={{ base }}>
<script>
document.querySelectorAll('.home-button').forEach(btn => {
btn.addEventListener('click', e => {
e.preventDefault();
if (window.matchMedia("(max-width: 640px)").matches) {
e.preventDefault();
document.querySelector('nav')?.classList.toggle('open');
}
else {
window.location.href = base;
}
});
});
</script>
Expand Down
12 changes: 6 additions & 6 deletions src/layouts/Default.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Footer from "../components/Footer.astro";
import Navbar from "../components/Navbar.astro";
const { title, description } = Astro.props;
const urlBase = import.meta.env.BASE_URL.endsWith('/') ? import.meta.env.BASE_URL.slice(0, -1) : import.meta.env.BASE_URL;
---

<html lang="en">
Expand All @@ -16,28 +17,27 @@ const { title, description } = Astro.props;
<!-- title, desc and icon -->
<title>{title}</title>
<meta name="description" content={description}>
<link rel="icon" type="image/png" href={`${import.meta.env.BASE_URL}/logo.png`} />
<link rel="icon" type="image/png" href={`${urlBase}/logo.png`} />

<!-- some embed bullshit idk -->
<meta property="og:url" content={import.meta.env.SITE}>
<meta property="og:url" content={Astro.site}>
<meta property="og:type" content="website">
<meta property="og:title" content="Globed - Multiplayer for Geometry Dash">
<meta property="og:description" content={description}>
<meta property="og:image" content={`${import.meta.env.BASE_URL}/logo.png`}>
<meta property="og:image" content={`${urlBase}/logo.png`}>
<meta property="og:image:width" content="80">
<meta property="og:image:height" content="80">

<meta name="twitter:card" content="summary">
<meta property="twitter:url" content={import.meta.env.SITE}>
<meta property="twitter:url" content={Astro.site}>
<meta name="twitter:title" content="Globed - Multiplayer for Geometry Dash">
<meta name="twitter:description" content={description}>
<meta property="twitter:image:src" content={`${import.meta.env.BASE_URL}/logo.png`}>
<meta property="twitter:image:src" content={`${urlBase}/logo.png`}>

<!-- fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Figtree:ital,wght@0,300..900;1,300..900&family=Open+Sans:ital,wght@0,300..900;1,300..900&display=swap" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
</head>

<body class="bg-wallpaper-darkest flex flex-col justify-stretch items-center">
Expand Down

0 comments on commit dbcaf6c

Please sign in to comment.