Skip to content

Commit 2d4ffa7

Browse files
committed
feat: add Visor to example site
1 parent d811127 commit 2d4ffa7

File tree

9 files changed

+64
-14
lines changed

9 files changed

+64
-14
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-check
2-
import { defineConfig } from 'astro/config';
2+
import {defineConfig} from "astro/config";
33

44
// https://astro.build/config
55
export default defineConfig({});

examples/example-site/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"dependencies": {
1313
"astro": "^4.16.7",
1414
"@astrojs/check": "^0.9.4",
15-
"typescript": "^5.6.3"
15+
"typescript": "^5.6.3",
16+
"@binz/visor": "workspace:*"
1617
}
1718
}
Lines changed: 9 additions & 0 deletions
Loading

examples/example-site/src/layouts/Layout.astro

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
---
2+
import {Visor} from '@binz/visor';
3+
import logoSvgSrc from '../images/Logo.svg';
4+
25
interface Props {
3-
title: string;
6+
title: string;
47
}
58
6-
const { title } = Astro.props;
9+
const { title: pageTitle } = Astro.props;
10+
const canonicalUrl = Astro.url; // requires `site` in astro.config.mjs
711
---
812

913
<!doctype html>
1014
<html lang="en">
11-
<head>
12-
<meta charset="UTF-8" />
13-
<meta name="description" content="Astro description" />
14-
<meta name="viewport" content="width=device-width" />
15-
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
16-
<meta name="generator" content={Astro.generator} />
17-
<title>{title}</title>
18-
</head>
15+
<Visor
16+
author={{
17+
name: "Joe Bloggs",
18+
twitterHandle: "@joe_blogs"
19+
}}
20+
canonicalURL={canonicalUrl}
21+
description="Built with visor"
22+
defaultKeywords={[]}
23+
siteName="Example Site"
24+
siteFaviconSvg={logoSvgSrc}
25+
socialImagePath="/social.jpg"
26+
title={pageTitle}
27+
/>
1928
<body>
2029
<slot />
2130
</body>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type {APIRoute} from "astro";
2+
import Favicon from "@binz/visor/src/lib/favicon";
3+
import path from "node:path";
4+
5+
const faviconSrc = path.resolve("src/images/Logo.svg");
6+
7+
export const GET: APIRoute = Favicon({faviconSrc});

examples/example-site/src/pages/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import Card from '../components/Card.astro';
3333
</linearGradient>
3434
</defs>
3535
</svg>
36-
<h1>Welcome to <span class="text-gradient">Astro</span></h1>
36+
<h1>Welcome to <span class="text-gradient">Visor</span></h1>
3737
<p class="instructions">
3838
To get started, open the directory <code>src/pages</code> in your project.<br />
3939
<strong>Code Challenge:</strong> Tweak the "Welcome to Astro" message above.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import path from "node:path";
2+
import type {APIRoute} from "astro";
3+
import Manifest from "@binz/visor/src/lib/manifest";
4+
5+
import favicon from "../images/favicon.ico";
6+
7+
const faviconPngSizes = [192, 512];
8+
9+
export const GET: APIRoute = Manifest({
10+
name: "Example Site",
11+
description: "An example site",
12+
start_url: "/",
13+
display: "standalone",
14+
id: "example-com",
15+
background_color: "#FFFFFF",
16+
theme_color: "#B9FF66",
17+
favicon: {
18+
src: favicon,
19+
faviconSizes: faviconPngSizes,
20+
},
21+
});

packages/visor/src/components/Head.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const appleTouchIcon = await getImage({
6666
})
6767
// const faviconSvg = await getImage({ src: siteFaviconSvg, format: 'svg' })
6868
69-
const canonicalImageSrc = new URL(socialImage, Astro.site);
69+
const canonicalImageSrc = new URL(socialImage, canonicalURL)
7070
const sanitizedDescription = description.replace(/(<([^>]+)>)/gi, '');
7171
7272
const keywords = Array.from(

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)