Skip to content

Commit

Permalink
Check whether base URL ends with a slash
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHauksson committed Oct 23, 2024
1 parent e52dd44 commit 303222e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
1 change: 0 additions & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import react from "@astrojs/react";

// https://astro.build/config
export default defineConfig({
trailingSlash: "never",
integrations: [tailwind(), icon(), mdx(), react()],
markdown: {
shikiConfig: {
Expand Down
9 changes: 3 additions & 6 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface Props {
const { title, description, favicon, thumbnail } = Astro.props.frontmatter;
const baseUrl = import.meta.env.BASE_URL;
const prefix = baseUrl.endsWith("/") ? baseUrl : baseUrl + "/";
---

<!doctype html>
Expand All @@ -20,16 +21,12 @@ const baseUrl = import.meta.env.BASE_URL;
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />

<link rel="icon" type="image/svg+xml" href={baseUrl + "/" + favicon} />
<link rel="icon" type="image/svg+xml" href={prefix + favicon} />

<meta property="og:title" content={title} />
{description && <meta property="og:description" content={description} />}
<meta property="og:type" content="website" />
{
thumbnail && (
<meta property="og:image" content={baseUrl + "/" + thumbnail} />
)
}
{thumbnail && <meta property="og:image" content={prefix + thumbnail} />}

<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
Expand Down

0 comments on commit 303222e

Please sign in to comment.