Skip to content

Commit 0e65931

Browse files
committed
refactor: add readme to package
1 parent 36132f9 commit 0e65931

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed

packages/visor/README.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Visor
2+
3+
Full-coverage `<head>` gear for your Astro app.
4+
5+
Visor automatically generates the necessary HTML tags for global metadata, including:
6+
7+
<meta> tags for charset, viewport, theme color, and description.
8+
<link> tags for favicon and canonical URL.
9+
<meta> tags for OpenGraph and Twitter tags, including title, description, image, and more.
10+
<meta> tag for the generator (Astro version).
11+
12+
You can customize the values of these tags by passing the appropriate props to the <Head> component.
13+
14+
## Installation
15+
16+
To install Visor, run one of the following commands in your Astro project:
17+
18+
```bash
19+
pnpm install @binz/visor
20+
```
21+
22+
```bash
23+
npm install @binz/visor
24+
```
25+
26+
```bash
27+
yarn add @binz/visor
28+
```
29+
30+
## Usage
31+
32+
Import the <Head> component from the Visor package and use it in your Astro Layout component:
33+
34+
```jsx
35+
// src/layouts/default.astro
36+
---
37+
import { Head } from '@binz/visor/Head.astro'
38+
import logoSvgSrc from '../../public/Logo.svg';
39+
---
40+
<html lang="en">
41+
<Head
42+
author={{{
43+
name: "Joe Bloggs",
44+
twitterHandle: "@joe_blogs"
45+
}}}
46+
canonicalURL="https://example.com"
47+
description="Built with visor"
48+
defaultKeywords={[]}
49+
siteName="Example Site"
50+
siteFaviconSvg={logoSvgSrc}
51+
socialImagePath="/social.jpg"
52+
title="Example Site"
53+
/>
54+
<body>
55+
<!-- Your content here -->
56+
</body>
57+
</html>
58+
```
59+
60+
Visor simplifies dynamic favicon generation with a pre-configured `favicon.ico` file.
61+
62+
```ts
63+
// pages/favicon.ico
64+
import type { APIRoute } from "astro";
65+
import Favicon from "../lib/favicon";
66+
import path from "node:path";
67+
68+
const faviconSrc = path.resolve("src/images/Logo.svg");
69+
70+
export const GET: APIRoute = Favicon({ faviconSrc });
71+
```
72+
73+
Visor can also be used to generate a `manifest.json` file for PWA support using Astro’s [Static File Endpoints feature](https://docs.astro.build/en/core-concepts/endpoints/).
74+
75+
Add the `pwa` prop to the <Head> component in your Astro layout:
76+
77+
```jsx
78+
// src/layouts/default.astro
79+
<Head
80+
title="Example Site"
81+
{'...'}
82+
pwa
83+
/>
84+
```
85+
86+
Then create a new API route to generate the `manifest.json` file:
87+
88+
```ts
89+
// pages/manifest.json.ts
90+
import type {APIRoute} from "astro";
91+
import Manifest from "../src/lib/manifest";
92+
93+
import favicon from "../images/Logo.svg";
94+
95+
const faviconPngSizes = [192, 512];
96+
97+
export const GET: APIRoute = Manifest({
98+
name: "Example Site",
99+
description: "An example site",
100+
start_url: "/",
101+
display: "standalone",
102+
id: "example-com",
103+
background_color: "#FFFFFF",
104+
theme_color: "#B9FF66",
105+
favicon: {
106+
src: favicon,
107+
faviconSizes: faviconPngSizes,
108+
},
109+
});
110+
111+
```
112+
113+
## License
114+
This Astro Head component is open source and available under the MIT License.

0 commit comments

Comments
 (0)