@astropub/doc
Advanced tools
Comparing version
@@ -10,24 +10,50 @@ export * from './astro-meta' | ||
export interface Props { | ||
export interface GlobalAttributes { | ||
/** List of space-separated classes for the element. */ | ||
class?: string | ||
/** How the element should be editable by the user. */ | ||
contenteditable?: '' | 'true' | 'false' | 'caret' | 'events' | 'plaintext-only' | 'typing' | boolean | string | ||
/** Directionality of the element's text. */ | ||
dir?: 'ltr' | 'rtl' | 'auto' | string | ||
/** How the element is relevant. */ | ||
hidden?: '' | 'until-found' | boolean | string | ||
/** Unique identifier for the element. */ | ||
id?: string | ||
/** Page IETF language identifier. */ | ||
lang?: LanguageCode | string | ||
/** Styling applied to the element. */ | ||
style?: string | ||
/** How the attributes, values, and text should be translated when localized. */ | ||
translate?: '' | 'no' | 'yes' | ||
} | ||
export interface Props extends GlobalAttributes { | ||
/** Defines the character encoding for the document. By default, this is `utf-8`. */ | ||
charset?: 'utf-8' | string | ||
class?: string | ||
/** Defines whether the website is compatible without adaptations smaller viewports. */ | ||
disabledadaptations?: 'watch' | string | ||
/** How search engines should follow the document. */ | ||
robots?: Robots | `${Robots},${Robots}` | string | ||
/** Page title used by embeds. */ | ||
/** Title of the document, without any additional taglines. */ | ||
title?: string | ||
/** Page title used in tab experiences. */ | ||
/** Title of the document used by the tab, which may include additional taglines. */ | ||
tabtitle?: string | ||
/** Page type used by embeds. */ | ||
/** Category type of the document. By default, this is `webpage`. */ | ||
type?: OpenGraph | string | ||
/** Page description used by embeds. */ | ||
/** Summary of the content of the document. */ | ||
description?: string | ||
/** Page URL used by embeds. */ | ||
/** Canonical URL of the document. */ | ||
url?: string | URL | ||
@@ -45,3 +71,3 @@ | ||
/** Page icon used in tab experiences. */ | ||
favicon?: '/favicon.ico' | '/favicon.svg' | string | ||
icon?: '/icon.ico' | '/icon.svg' | string | ||
@@ -51,7 +77,6 @@ /** Page icon used in app experiences. */ | ||
/** Summary card used by Twitter. */ | ||
twittercard?: 'summary' | 'summary_large_image' | string | ||
/** Page IETF language identifier. */ | ||
lang?: LanguageCode | string | ||
/** Area through which the document is viewed. */ | ||
viewport?: 'width=device-width' | string | ||
@@ -58,0 +83,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"description": "Create document layouts with minimal markup in Astro", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"type": "module", | ||
@@ -42,2 +42,3 @@ "license": "CC0-1.0", | ||
"performance", | ||
"seo", | ||
"attribute", | ||
@@ -52,6 +53,14 @@ "attributes", | ||
"elements", | ||
"engine", | ||
"favicon", | ||
"head", | ||
"html", | ||
"icon", | ||
"layout", | ||
"tag" | ||
"optimize", | ||
"optimized", | ||
"search", | ||
"tag", | ||
"title", | ||
"touchicon" | ||
], | ||
@@ -58,0 +67,0 @@ "author": "Jonathan Neal <jonathantneal@hotmail.com>", |
213
README.md
@@ -6,6 +6,14 @@ # Astro Doc | ||
[![NPM Version][npm-img]][npm-url] | ||
[![Open in StackBlitz][stackblitz-img]][stackblitz-url] | ||
[![NPM Downloads][download-img]][download-url] | ||
You write this: | ||
```astro | ||
<Document> | ||
--- | ||
import Document from '@astropub/doc' | ||
--- | ||
<Document title="Astro Doc" body-class="p-body"> | ||
<h1> | ||
Astro Doc | ||
</h1> | ||
<p> | ||
@@ -17,2 +25,27 @@ The HTML, HEAD, and BODY tags are all set. | ||
You get this: | ||
```html | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Astro Doc</title> | ||
<meta name="viewport" content="width=device-width" /> | ||
<meta name="disabled-adaptations" content="watch" /> | ||
<meta property="og:title" content="Astro Doc" /> | ||
</head> | ||
<body class="p-body"> | ||
<h1> | ||
Astro Doc | ||
</h1> | ||
<p> | ||
The HTML, HEAD, and BODY tags are all set. | ||
</p> | ||
</body> | ||
</html> | ||
``` | ||
[![Open in StackBlitz][stackblitz-img]][stackblitz-url] | ||
## Usage | ||
@@ -30,5 +63,169 @@ | ||
--- | ||
import { Document } from '@astropub/doc' | ||
import Document from '@astropub/doc' | ||
--- | ||
<Document title="Astro Doc" charset="utf-8" body-class="p-body"> | ||
<Document> | ||
<p> | ||
The HTML, HEAD, and BODY tags are all set. | ||
</p> | ||
</Document> | ||
``` | ||
You get this: | ||
```html | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<meta name="disabled-adaptations" content="watch" /> | ||
</head> | ||
<body> | ||
<p> | ||
The HTML, HEAD, and BODY tags are all set. | ||
</p> | ||
</body> | ||
</html> | ||
``` | ||
## Features | ||
### Embedded Attributes | ||
#### title | ||
Defines the title of the document, without any additional taglines. | ||
```jsx | ||
<meta property="og:title" content={title} /> | ||
``` | ||
#### description | ||
Defines the summary of the content of the current document. | ||
```jsx | ||
<meta name="description" content={description} /> | ||
``` | ||
#### sitetitle | ||
Defines the title of the site, without any additional taglines. | ||
```jsx | ||
<meta property="og:site_name" content={sitetitle} /> | ||
``` | ||
#### tabtitle | ||
Defines the title of the document used by the tab, which may include additional taglines. | ||
```jsx | ||
<title>{title}</title> | ||
``` | ||
#### type | ||
Defines the category or type of the current document. By default, this is **webpage**. | ||
```jsx | ||
<meta property="og:type" content={type} /> | ||
``` | ||
#### url | ||
Defines the canonical URL of the current document. By default, this is the value of `Astro.url`. If the URL does not include a protocol or domain, it will be resolved against `Astro.site`. | ||
```jsx | ||
<meta property="og:url" content={resolvedURL(url)} /> | ||
``` | ||
#### imageurl | ||
Defines the URL of the image representing the current document. If the URL does not include a protocol or domain, it will be resolved against `Astro.site`. | ||
```jsx | ||
<meta property="og:image" content={resolvedURL(imageurl)} /> | ||
``` | ||
#### imagealt | ||
Defines the description for the image representing the current document. | ||
```jsx | ||
<meta property="og:image:alt" content={imagealt} /> | ||
``` | ||
#### twittercard | ||
Defines the summary card used by Twitter. By default, this is `summary_large_image` if `imageurl` is defined. | ||
```jsx | ||
<meta name="twitter:card" content={twittercard} /> | ||
``` | ||
_Note: This is the only embedded attribute not shared across social networks._ | ||
#### robots | ||
How search engines should follow the current document. | ||
```jsx | ||
<meta name="robots" content={robots} /> | ||
``` | ||
### Application Attributes | ||
#### viewport | ||
Defines the area through which the document is viewed. | ||
```jsx | ||
<meta name="viewport" content={viewport} /> | ||
``` | ||
#### disabledadaptations | ||
Defines whether the website is compatible without adaptations smaller viewports. | ||
```jsx | ||
<meta name="disabled-adaptations" content={disabledadaptations} /> | ||
``` | ||
#### icon | ||
Defines the image used by the website to represent the current document in some browser tabs, browser history views, toolbar apps, bookmarks dropdowns, search bars, and search bar recommendations. The `type` will be automatically detected. | ||
```jsx | ||
<link rel="icon" href={icon} type={resolvedIconType(icon)} /> | ||
``` | ||
#### touchicon | ||
Defines the image used by common handheld devices, such as Apple or Android phones. Presently, the size is hard-coded to `180x180`. | ||
```jsx | ||
<link rel="apple-touch-icon" sizes="180x180" href={touchicon} /> | ||
``` | ||
#### charset | ||
Defines the character encoding for the document. By default, this is `utf-8`. | ||
```jsx | ||
<meta charset={charset} /> | ||
``` | ||
### Head Slot | ||
Additional elements may be placed in the `<head>` tag thru use of the `head` slot. | ||
```astro | ||
--- | ||
import Document from '@astropub/doc' | ||
--- | ||
<Document title="Astro Doc" body-class="p-body"> | ||
<meta slot="head" name="twitter:creator" content="@jon_neal" /> | ||
<link slot="head" rel="alternate" type="application/rss+xml" title="Blog" href="/blog.xml" /> | ||
<h1> | ||
@@ -43,4 +240,2 @@ Astro Doc | ||
Enjoy! | ||
[npm-img]: https://img.shields.io/npm/v/@astropub/doc?color=%23444&label=&labelColor=%23CB0000&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjE1MCAxNTAgNDAwIDQwMCIgZmlsbD0iI0ZGRiI+PHBhdGggZD0iTTE1MCA1NTBoMjAwVjI1MGgxMDB2MzAwaDEwMFYxNTBIMTUweiIvPjwvc3ZnPg==&style=for-the-badge | ||
@@ -50,1 +245,7 @@ [npm-url]: https://www.npmjs.com/package/@astropub/doc | ||
[stackblitz-url]: https://stackblitz.com/github/astro-community/astro-doc | ||
[bundlejs-img]: https://img.shields.io/badge/dynamic/json?url=https://bundlejs.com/api?q=@astropub/doc&query=size.totalCompressedSize&color=%23444&labelColor=%233B82F6&label=&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA3MDAgNzAwIiBmaWxsPSIjRkZGIj4KCTxwYXRoIGQ9Ik0xNDYgMkExNzEgMTcxIDAgMCAwIDMgMTM5bC0yIDExdjQwMmwyIDExYzE1IDcyIDcxIDEyNSAxNDMgMTM2bDIwOSAxIDE5OS0xIDktMmM3MC0xNiAxMTktNjYgMTM0LTEzNWwyLTEwVjE1MGwtMi0xMkExNzEgMTcxIDAgMCAwIDU2MiAzbC0xMC0yLTE5OS0xQzE4NyAwIDE1MyAwIDE0NiAyem0xODEgMjUxdjM2bDctM2MxMy02IDMzLTkgNTAtNyA0MSA1IDcwIDM0IDgwIDc4IDIgMTIgMiA0MSAwIDUzLTUgMjItMTMgMzgtMjcgNTJhODIgODIgMCAwIDEtNjMgMjZjLTE1IDAtMTkgMC0yNS0yLTEwLTItMTctNi0yNC0xMGwtNS0zdjExaC00NVYyMTdoNTJ2MzZ6bTI5IDcxYy0yMCAzLTMyIDE5LTM1IDQ4LTMgMjUgMyA0OCAxNCA2MCA1IDYgMTMgMTAgMjMgMTEgMjUgNCA0NC05IDUxLTM2bDMtMTljMC0xNy0xLTI3LTctMzktOS0xOS0yNi0yOC00OS0yNXoiLz4KPC9zdmc+&style=for-the-badge | ||
[bundlejs-url]: https://bundlejs.com/?bundle&q=@astropub/doc | ||
[license-img]: https://img.shields.io/npm/l/@astropub/doc?color=%23444&labelColor=%232DA44E&label=&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCIgZmlsbD0iI0ZG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url]: https://choosealicense.com/licenses/cc0-1.0/ | ||
[download-url]: https://www.npmjs.com/package/@astropub/doc | ||
[download-img]: https://img.shields.io/badge/dynamic/json?url=https://api.npmjs.org/downloads/point/last-week/@astropub/doc&query=downloads&label=↓/week&color=%23444&labelColor=%23EEd100&style=for-the-badge |
Sorry, the diff of this file is not supported yet
23065
53.81%126
18.87%247
436.96%