@mannisto/astro-metadata 1.0.2 → 2.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +427 -82
- package/package.json +25 -14
- package/src/assets/icons/LICENSE.md +35 -0
- package/src/assets/icons/binoculars.svg +1 -0
- package/src/assets/icons/caret-right.svg +1 -0
- package/src/assets/icons/check.svg +1 -0
- package/src/assets/icons/copy.svg +1 -0
- package/src/assets/icons/seal-check-duotone.svg +1 -0
- package/src/assets/icons/seal-question-duotone.svg +1 -0
- package/src/assets/icons/warning-circle-duotone.svg +1 -0
- package/src/assets/icons/warning-duotone.svg +1 -0
- package/src/assets/icons/x.svg +1 -0
- package/src/components/Metadata.astro +145 -0
- package/src/components/index.ts +2 -0
- package/src/integration.d.ts +112 -0
- package/src/integration.js +508 -0
- package/src/lib/checks.d.ts +70 -0
- package/src/lib/checks.js +193 -0
- package/src/lib/config.ts +111 -0
- package/src/lib/favicon-files.d.ts +29 -0
- package/src/lib/favicon-files.js +103 -0
- package/src/lib/favicon-image.ts +124 -0
- package/src/lib/favicon.ts +167 -0
- package/src/lib/head.d.ts +25 -0
- package/src/lib/head.js +141 -0
- package/src/lib/manifest.ts +126 -0
- package/src/lib/rules.d.ts +73 -0
- package/src/lib/rules.js +929 -0
- package/src/lib/schema.ts +208 -0
- package/src/lib/site.ts +72 -0
- package/src/lib/url.ts +79 -0
- package/src/routes/favicon.ts +14 -0
- package/src/routes/manifest.ts +18 -0
- package/src/runtime.ts +16 -0
- package/src/toolbar/app.ts +72 -0
- package/src/toolbar/assets.ts +81 -0
- package/src/toolbar/data.ts +282 -0
- package/src/toolbar/define.ts +7 -0
- package/src/toolbar/env.d.ts +10 -0
- package/src/toolbar/highlight.ts +83 -0
- package/src/toolbar/styles/shared.css +18 -0
- package/src/toolbar/styles/tokens.css +182 -0
- package/src/toolbar/toolbar-badge.ts +78 -0
- package/src/toolbar/ui/alert/alert.css +126 -0
- package/src/toolbar/ui/alert/alert.ts +102 -0
- package/src/toolbar/ui/badge/badge.css +41 -0
- package/src/toolbar/ui/badge/badge.ts +24 -0
- package/src/toolbar/ui/code-block/code-block.css +90 -0
- package/src/toolbar/ui/code-block/code-block.ts +68 -0
- package/src/toolbar/ui/color-swatch/color-swatch.css +15 -0
- package/src/toolbar/ui/color-swatch/color-swatch.ts +31 -0
- package/src/toolbar/ui/icon/icon.css +11 -0
- package/src/toolbar/ui/icon/icon.ts +46 -0
- package/src/toolbar/ui/image/image.css +18 -0
- package/src/toolbar/ui/image/image.ts +58 -0
- package/src/toolbar/ui/inline-code/inline-code.css +16 -0
- package/src/toolbar/ui/inline-code/inline-code.ts +41 -0
- package/src/toolbar/ui/section/section.css +88 -0
- package/src/toolbar/ui/section/section.ts +78 -0
- package/src/toolbar/ui/tab/tab.css +7 -0
- package/src/toolbar/ui/tab/tab.ts +47 -0
- package/src/toolbar/ui/tab-group/tab-group.css +42 -0
- package/src/toolbar/ui/tab-group/tab-group.ts +101 -0
- package/src/toolbar/ui/table/table.css +124 -0
- package/src/toolbar/ui/table/table.ts +155 -0
- package/src/toolbar/views/code-blocks.ts +35 -0
- package/src/toolbar/views/metadata-panel.css +105 -0
- package/src/toolbar/views/metadata-panel.ts +125 -0
- package/src/toolbar/views/overview-view.css +27 -0
- package/src/toolbar/views/overview-view.ts +401 -0
- package/src/toolbar/views/previews/discord.css +70 -0
- package/src/toolbar/views/previews/discord.ts +60 -0
- package/src/toolbar/views/previews/facebook.css +65 -0
- package/src/toolbar/views/previews/facebook.ts +36 -0
- package/src/toolbar/views/previews/google.css +75 -0
- package/src/toolbar/views/previews/google.ts +36 -0
- package/src/toolbar/views/previews/linkedin.css +58 -0
- package/src/toolbar/views/previews/linkedin.ts +34 -0
- package/src/toolbar/views/previews/page.ts +129 -0
- package/src/toolbar/views/previews/platform.ts +14 -0
- package/src/toolbar/views/previews/previews-view.css +37 -0
- package/src/toolbar/views/previews/previews-view.ts +52 -0
- package/src/toolbar/views/previews/slack.css +61 -0
- package/src/toolbar/views/previews/slack.ts +47 -0
- package/src/toolbar/views/previews/twitter.css +89 -0
- package/src/toolbar/views/previews/twitter.ts +57 -0
- package/src/toolbar/views/previews/whatsapp.css +88 -0
- package/src/toolbar/views/previews/whatsapp.ts +65 -0
- package/src/toolbar/views/raw-view.ts +41 -0
- package/index.ts +0 -31
- package/src/components/Canonical.astro +0 -11
- package/src/components/Description.astro +0 -9
- package/src/components/Favicon.astro +0 -96
- package/src/components/Head.astro +0 -94
- package/src/components/Keywords.astro +0 -9
- package/src/components/LanguageAlternates.astro +0 -18
- package/src/components/OpenGraph.astro +0 -75
- package/src/components/Robots.astro +0 -25
- package/src/components/Schema.astro +0 -18
- package/src/components/Title.astro +0 -13
- package/src/components/Twitter.astro +0 -27
- package/src/lib/metadata.ts +0 -77
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M216,28H88A12,12,0,0,0,76,40V76H40A12,12,0,0,0,28,88V216a12,12,0,0,0,12,12H168a12,12,0,0,0,12-12V180h36a12,12,0,0,0,12-12V40A12,12,0,0,0,216,28ZM156,204H52V100H156Zm48-48H180V88a12,12,0,0,0-12-12H100V52H204Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M232,128c0,12.51-17.82,21.95-22.68,33.69-4.68,11.32,1.42,30.65-7.78,39.85s-28.53,3.1-39.85,7.78C150,214.18,140.5,232,128,232s-22-17.82-33.69-22.68c-11.32-4.68-30.65,1.42-39.85-7.78s-3.1-28.53-7.78-39.85C41.82,150,24,140.5,24,128s17.82-22,22.68-33.69C51.36,83,45.26,63.66,54.46,54.46S83,51.36,94.31,46.68C106.05,41.82,115.5,24,128,24S150,41.82,161.69,46.68c11.32,4.68,30.65-1.42,39.85,7.78s3.1,28.53,7.78,39.85C214.18,106.05,232,115.5,232,128Z" opacity="0.2"/><path d="M225.86,102.82c-3.77-3.94-7.67-8-9.14-11.57-1.36-3.27-1.44-8.69-1.52-13.94-.15-9.76-.31-20.82-8-28.51s-18.75-7.85-28.51-8c-5.25-.08-10.67-.16-13.94-1.52-3.56-1.47-7.63-5.37-11.57-9.14C146.28,23.51,138.44,16,128,16s-18.27,7.51-25.18,14.14c-3.94,3.77-8,7.67-11.57,9.14C88,40.64,82.56,40.72,77.31,40.8c-9.76.15-20.82.31-28.51,8S41,67.55,40.8,77.31c-.08,5.25-.16,10.67-1.52,13.94-1.47,3.56-5.37,7.63-9.14,11.57C23.51,109.72,16,117.56,16,128s7.51,18.27,14.14,25.18c3.77,3.94,7.67,8,9.14,11.57,1.36,3.27,1.44,8.69,1.52,13.94.15,9.76.31,20.82,8,28.51s18.75,7.85,28.51,8c5.25.08,10.67.16,13.94,1.52,3.56,1.47,7.63,5.37,11.57,9.14C109.72,232.49,117.56,240,128,240s18.27-7.51,25.18-14.14c3.94-3.77,8-7.67,11.57-9.14,3.27-1.36,8.69-1.44,13.94-1.52,9.76-.15,20.82-.31,28.51-8s7.85-18.75,8-28.51c.08-5.25.16-10.67,1.52-13.94,1.47-3.56,5.37-7.63,9.14-11.57C232.49,146.28,240,138.44,240,128S232.49,109.73,225.86,102.82Zm-11.55,39.29c-4.79,5-9.75,10.17-12.38,16.52-2.52,6.1-2.63,13.07-2.73,19.82-.1,7-.21,14.33-3.32,17.43s-10.39,3.22-17.43,3.32c-6.75.1-13.72.21-19.82,2.73-6.35,2.63-11.52,7.59-16.52,12.38S132,224,128,224s-9.15-4.92-14.11-9.69-10.17-9.75-16.52-12.38c-6.1-2.52-13.07-2.63-19.82-2.73-7-.1-14.33-.21-17.43-3.32s-3.22-10.39-3.32-17.43c-.1-6.75-.21-13.72-2.73-19.82-2.63-6.35-7.59-11.52-12.38-16.52S32,132,32,128s4.92-9.15,9.69-14.11,9.75-10.17,12.38-16.52c2.52-6.1,2.63-13.07,2.73-19.82.1-7,.21-14.33,3.32-17.43S70.51,56.9,77.55,56.8c6.75-.1,13.72-.21,19.82-2.73,6.35-2.63,11.52-7.59,16.52-12.38S124,32,128,32s9.15,4.92,14.11,9.69,10.17,9.75,16.52,12.38c6.1,2.52,13.07,2.63,19.82,2.73,7,.1,14.33.21,17.43,3.32s3.22,10.39,3.32,17.43c.1,6.75.21,13.72,2.73,19.82,2.63,6.35,7.59,11.52,12.38,16.52S224,124,224,128,219.08,137.15,214.31,142.11ZM173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M232,128c0,12.51-17.82,21.95-22.68,33.69-4.68,11.32,1.42,30.64-7.78,39.85s-28.53,3.1-39.85,7.78C150,214.18,140.5,232,128,232s-22-17.82-33.69-22.68c-11.32-4.68-30.65,1.42-39.85-7.78s-3.1-28.53-7.78-39.85C41.82,150,24,140.5,24,128s17.82-22,22.68-33.69C51.36,83,45.26,63.66,54.46,54.46S83,51.36,94.31,46.68C106.05,41.82,115.5,24,128,24S150,41.82,161.69,46.68c11.32,4.68,30.65-1.42,39.85,7.78s3.1,28.53,7.78,39.85C214.18,106.05,232,115.5,232,128Z" opacity="0.2"/><path d="M225.86,102.82c-3.77-3.94-7.67-8-9.14-11.57-1.36-3.27-1.44-8.69-1.52-13.94-.15-9.76-.31-20.82-8-28.51s-18.75-7.85-28.51-8c-5.25-.08-10.67-.16-13.94-1.52-3.56-1.47-7.63-5.37-11.57-9.14C146.28,23.51,138.44,16,128,16s-18.27,7.51-25.18,14.14c-3.94,3.77-8,7.67-11.57,9.14C88,40.64,82.56,40.72,77.31,40.8c-9.76.15-20.82.31-28.51,8S41,67.55,40.8,77.31c-.08,5.25-.16,10.67-1.52,13.94-1.47,3.56-5.37,7.63-9.14,11.57C23.51,109.72,16,117.56,16,128s7.51,18.27,14.14,25.18c3.77,3.94,7.67,8,9.14,11.57,1.36,3.27,1.44,8.69,1.52,13.94.15,9.76.31,20.82,8,28.51s18.75,7.85,28.51,8c5.25.08,10.67.16,13.94,1.52,3.56,1.47,7.63,5.37,11.57,9.14C109.72,232.49,117.56,240,128,240s18.27-7.51,25.18-14.14c3.94-3.77,8-7.67,11.57-9.14,3.27-1.36,8.69-1.44,13.94-1.52,9.76-.15,20.82-.31,28.51-8s7.85-18.75,8-28.51c.08-5.25.16-10.67,1.52-13.94,1.47-3.56,5.37-7.63,9.14-11.57C232.49,146.28,240,138.44,240,128S232.49,109.73,225.86,102.82Zm-11.55,39.29c-4.79,5-9.75,10.17-12.38,16.52-2.52,6.1-2.63,13.07-2.73,19.82-.1,7-.21,14.33-3.32,17.43s-10.39,3.22-17.43,3.32c-6.75.1-13.72.21-19.82,2.73-6.35,2.63-11.52,7.59-16.52,12.38S132,224,128,224s-9.15-4.92-14.11-9.69-10.17-9.75-16.52-12.38c-6.1-2.52-13.07-2.63-19.82-2.73-7-.1-14.33-.21-17.43-3.32s-3.22-10.39-3.32-17.43c-.1-6.75-.21-13.72-2.73-19.82-2.63-6.35-7.59-11.52-12.38-16.52S32,132,32,128s4.92-9.15,9.69-14.11,9.75-10.17,12.38-16.52c2.52-6.1,2.63-13.07,2.73-19.82.1-7,.21-14.33,3.32-17.43S70.51,56.9,77.55,56.8c6.75-.1,13.72-.21,19.82-2.73,6.35-2.63,11.52-7.59,16.52-12.38S124,32,128,32s9.15,4.92,14.11,9.69,10.17,9.75,16.52,12.38c6.1,2.52,13.07,2.63,19.82,2.73,7,.1,14.33.21,17.43,3.32s3.22,10.39,3.32,17.43c.1,6.75.21,13.72,2.73,19.82,2.63,6.35,7.59,11.52,12.38,16.52S224,124,224,128,219.08,137.15,214.31,142.11ZM140,180a12,12,0,1,1-12-12A12,12,0,0,1,140,180Zm28-72c0,17.38-13.76,31.93-32,35.28V144a8,8,0,0,1-16,0v-8a8,8,0,0,1,8-8c13.23,0,24-9,24-20s-10.77-20-24-20-24,9-24,20v4a8,8,0,0,1-16,0v-4c0-19.85,17.94-36,40-36S168,88.15,168,108Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z" opacity="0.2"/><path d="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M215.46,216H40.54C27.92,216,20,202.79,26.13,192.09L113.59,40.22c6.3-11,22.52-11,28.82,0l87.46,151.87C236,202.79,228.08,216,215.46,216Z" opacity="0.2"/><path d="M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM222.93,203.8a8.5,8.5,0,0,1-7.48,4.2H40.55a8.5,8.5,0,0,1-7.48-4.2,7.59,7.59,0,0,1,0-7.72L120.52,44.21a8.75,8.75,0,0,1,15,0l87.45,151.87A7.59,7.59,0,0,1,222.93,203.8ZM120,144V104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,180Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"/></svg>
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { localize } from "../lib/config.ts"
|
|
3
|
+
import type { MetadataImage } from "../lib/config.ts"
|
|
4
|
+
import { Favicon } from "../lib/favicon.ts"
|
|
5
|
+
import { Manifest } from "../lib/manifest.ts"
|
|
6
|
+
import { Schema } from "../lib/schema.ts"
|
|
7
|
+
import type { SchemaData } from "../lib/schema.ts"
|
|
8
|
+
import { Site } from "../lib/site.ts"
|
|
9
|
+
import { withBase } from "../lib/url.ts"
|
|
10
|
+
|
|
11
|
+
export type HreflangLink = {
|
|
12
|
+
/** The locale of the version, e.g. "en", "fi" or "en-US", or "x-default". */
|
|
13
|
+
hreflang: string
|
|
14
|
+
/** The path or URL of the page in that locale. */
|
|
15
|
+
href: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type Props = {
|
|
19
|
+
/** The page title. The title template of the config adds the site name. */
|
|
20
|
+
title?: string
|
|
21
|
+
/** Defaults to the description of the config. */
|
|
22
|
+
description?: string
|
|
23
|
+
/** The social image. Defaults to the image of the config. */
|
|
24
|
+
image?: MetadataImage
|
|
25
|
+
/** The Open Graph type, e.g. "article". Defaults to "website". */
|
|
26
|
+
type?: string
|
|
27
|
+
/** The Twitter (X) handle of the author, e.g. "@acmewriter". */
|
|
28
|
+
author?: string
|
|
29
|
+
/** The canonical path or URL. Defaults to the current page. */
|
|
30
|
+
canonical?: string
|
|
31
|
+
/** Set to false to keep the page out of search results. Defaults to true. */
|
|
32
|
+
index?: boolean
|
|
33
|
+
/** Set to false to tell search engines not to follow the links. Defaults to true. */
|
|
34
|
+
follow?: boolean
|
|
35
|
+
/**
|
|
36
|
+
* The hreflang links: the page in each locale, and `x-default`.
|
|
37
|
+
* The output of `Locale.hreflang()` of @mannisto/astro-i18n fits here.
|
|
38
|
+
*/
|
|
39
|
+
hreflang?: HreflangLink[]
|
|
40
|
+
/** JSON-LD structured data, e.g. from the `Schema` builders. */
|
|
41
|
+
schema?: SchemaData | SchemaData[]
|
|
42
|
+
/** The locale of the localized config values. Defaults to `Astro.currentLocale`. */
|
|
43
|
+
locale?: string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const props = Astro.props
|
|
47
|
+
const config = Site.config
|
|
48
|
+
const locale = props.locale ?? Astro.currentLocale
|
|
49
|
+
|
|
50
|
+
const siteName = Site.name(locale)
|
|
51
|
+
const title = Site.title(props.title, locale)
|
|
52
|
+
const description = props.description ?? localize(config.description, locale)
|
|
53
|
+
const image =
|
|
54
|
+
props.image ??
|
|
55
|
+
(config.image ? { ...config.image, alt: localize(config.image.alt, locale) } : undefined)
|
|
56
|
+
|
|
57
|
+
// Social cards show the page title without the template: og:site_name has the site name
|
|
58
|
+
const socialTitle = props.title ?? siteName
|
|
59
|
+
|
|
60
|
+
const canonical = Site.pageUrl(props.canonical ?? Astro.url.pathname)
|
|
61
|
+
|
|
62
|
+
// Search engines index and follow by default, so the tag is only necessary for other values
|
|
63
|
+
const index = props.index ?? config.robots?.index ?? true
|
|
64
|
+
const follow = props.follow ?? config.robots?.follow ?? true
|
|
65
|
+
const robots = [!index && "noindex", !follow && "nofollow", config.robots?.extra]
|
|
66
|
+
.filter(Boolean)
|
|
67
|
+
.join(", ")
|
|
68
|
+
|
|
69
|
+
// Twitter (X) uses the Open Graph title, description and image, so only the tags that
|
|
70
|
+
// are specific to Twitter (X) are necessary
|
|
71
|
+
const card = image ? (config.twitter?.card ?? "summary_large_image") : "summary"
|
|
72
|
+
|
|
73
|
+
const themeColor = config.themeColor
|
|
74
|
+
const manifest = Manifest.url(locale)
|
|
75
|
+
|
|
76
|
+
const FEED_TYPES = {
|
|
77
|
+
rss: "application/rss+xml",
|
|
78
|
+
atom: "application/atom+xml",
|
|
79
|
+
json: "application/feed+json",
|
|
80
|
+
}
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
<meta charset="UTF-8" />
|
|
84
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
85
|
+
{title && <title>{title}</title>}
|
|
86
|
+
{description && <meta name="description" content={description} />}
|
|
87
|
+
<link rel="canonical" href={canonical} />
|
|
88
|
+
{robots && <meta name="robots" content={robots} />}
|
|
89
|
+
{typeof themeColor === "string" && <meta name="theme-color" content={themeColor} />}
|
|
90
|
+
{
|
|
91
|
+
typeof themeColor === "object" && (
|
|
92
|
+
<>
|
|
93
|
+
<meta name="theme-color" content={themeColor.light} media="(prefers-color-scheme: light)" />
|
|
94
|
+
<meta name="theme-color" content={themeColor.dark} media="(prefers-color-scheme: dark)" />
|
|
95
|
+
</>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
{socialTitle && <meta property="og:title" content={socialTitle} />}
|
|
100
|
+
{description && <meta property="og:description" content={description} />}
|
|
101
|
+
<meta property="og:url" content={canonical} />
|
|
102
|
+
<meta property="og:type" content={props.type ?? "website"} />
|
|
103
|
+
{siteName && <meta property="og:site_name" content={siteName} />}
|
|
104
|
+
{
|
|
105
|
+
image && (
|
|
106
|
+
<>
|
|
107
|
+
<meta property="og:image" content={Site.url(image.url)} />
|
|
108
|
+
{image.alt && <meta property="og:image:alt" content={image.alt} />}
|
|
109
|
+
{image.width && <meta property="og:image:width" content={String(image.width)} />}
|
|
110
|
+
{image.height && <meta property="og:image:height" content={String(image.height)} />}
|
|
111
|
+
</>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
<meta name="twitter:card" content={card} />
|
|
115
|
+
{config.twitter?.site && <meta name="twitter:site" content={config.twitter.site} />}
|
|
116
|
+
{props.author && <meta name="twitter:creator" content={props.author} />}
|
|
117
|
+
|
|
118
|
+
{
|
|
119
|
+
Favicon.links().map((link) => {
|
|
120
|
+
return <link rel={link.rel} type={link.type} href={link.href} sizes={link.sizes} />
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
{manifest && <link rel="manifest" href={manifest} />}
|
|
124
|
+
{
|
|
125
|
+
config.feeds?.map((feed) => {
|
|
126
|
+
return (
|
|
127
|
+
<link
|
|
128
|
+
rel="alternate"
|
|
129
|
+
type={FEED_TYPES[feed.type ?? "rss"]}
|
|
130
|
+
title={localize(feed.title, locale)}
|
|
131
|
+
href={withBase(feed.href)}
|
|
132
|
+
/>
|
|
133
|
+
)
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
{
|
|
137
|
+
props.hreflang?.map((link) => {
|
|
138
|
+
return <link rel="alternate" hreflang={link.hreflang} href={Site.pageUrl(link.href)} />
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
{
|
|
142
|
+
props.schema && (
|
|
143
|
+
<script is:inline type="application/ld+json" set:html={Schema.stringify(props.schema)} />
|
|
144
|
+
)
|
|
145
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { AstroIntegration } from "astro"
|
|
2
|
+
|
|
3
|
+
import type { CheckOptions, CustomRule, HeadData } from "./lib/checks"
|
|
4
|
+
import type { MetadataConfig } from "./lib/config.ts"
|
|
5
|
+
import type { FaviconFile } from "./lib/favicon-files"
|
|
6
|
+
|
|
7
|
+
export type { FaviconFile, HeadData, MetadataConfig }
|
|
8
|
+
|
|
9
|
+
/** A check rule of your own, for the `rules.custom` option. */
|
|
10
|
+
export type MetadataRule = CustomRule
|
|
11
|
+
|
|
12
|
+
export type FaviconOptions = {
|
|
13
|
+
/**
|
|
14
|
+
* The path of the source image, relative to the project root. An SVG gives the best
|
|
15
|
+
* result. A PNG, WebP or JPEG source must be square and at least 512 px.
|
|
16
|
+
*
|
|
17
|
+
* @example "./src/assets/logo.svg"
|
|
18
|
+
*/
|
|
19
|
+
source: string
|
|
20
|
+
/**
|
|
21
|
+
* The background color of the Apple icon. iOS shows transparent pixels as black,
|
|
22
|
+
* so the icon needs a solid color. Defaults to "#ffffff".
|
|
23
|
+
*/
|
|
24
|
+
background?: string
|
|
25
|
+
/**
|
|
26
|
+
* The files to generate. This list replaces the default files. The format comes from
|
|
27
|
+
* the extension (.ico, .png or .svg), and the use comes from the name, format and size:
|
|
28
|
+
* `.ico` and `.svg` files get an icon link tag, `apple-touch-icon.png` gets the Apple
|
|
29
|
+
* link tag, other `.png` files smaller than 192 px get an icon link tag, and `.png`
|
|
30
|
+
* files of 192 px or larger go into the web app manifest.
|
|
31
|
+
*
|
|
32
|
+
* @default
|
|
33
|
+
* [
|
|
34
|
+
* { path: "/favicon.ico", sizes: [16, 32] },
|
|
35
|
+
* { path: "/favicon.svg" }, // only for an SVG source
|
|
36
|
+
* { path: "/favicon-16.png", size: 16 },
|
|
37
|
+
* { path: "/favicon-32.png", size: 32 },
|
|
38
|
+
* { path: "/apple-touch-icon.png", size: 180 },
|
|
39
|
+
* { path: "/favicon-192.png", size: 192 },
|
|
40
|
+
* { path: "/favicon-512.png", size: 512 },
|
|
41
|
+
* ]
|
|
42
|
+
*/
|
|
43
|
+
files?: FaviconFile[]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The options of the integration: the site values, which the props of `<Metadata>`
|
|
48
|
+
* override, and the build features.
|
|
49
|
+
*/
|
|
50
|
+
export type MetadataOptions = MetadataConfig & {
|
|
51
|
+
/**
|
|
52
|
+
* Generates the favicon files from one source image.
|
|
53
|
+
*/
|
|
54
|
+
favicon?: FaviconOptions
|
|
55
|
+
/**
|
|
56
|
+
* The debug features: the Metadata app in the Astro dev toolbar (`client`), and the
|
|
57
|
+
* checks of the built pages in the build log (`build`). Set to false to turn off both.
|
|
58
|
+
*
|
|
59
|
+
* @default true
|
|
60
|
+
* @example { client: true, build: false }
|
|
61
|
+
*/
|
|
62
|
+
debug?: boolean | { client?: boolean; build?: boolean }
|
|
63
|
+
/**
|
|
64
|
+
* The pages to check.
|
|
65
|
+
*/
|
|
66
|
+
pages?: {
|
|
67
|
+
/**
|
|
68
|
+
* The pages without checks, as path patterns without the base. `*` matches one part
|
|
69
|
+
* of the path, and `**` matches any number of parts. The dev toolbar app shows the
|
|
70
|
+
* other values of these pages, without problems.
|
|
71
|
+
*
|
|
72
|
+
* @example ["/404", "/drafts/**"]
|
|
73
|
+
*/
|
|
74
|
+
ignore?: string[]
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The check rules: turn off rules of the package, and add your own rules.
|
|
78
|
+
* The rules run in the dev toolbar app and in the build.
|
|
79
|
+
*/
|
|
80
|
+
rules?: {
|
|
81
|
+
/**
|
|
82
|
+
* The ids of the rules to turn off. The ids are in `src/lib/rules.js`.
|
|
83
|
+
*
|
|
84
|
+
* @example ["description-short", "og-image-alt-missing"]
|
|
85
|
+
*/
|
|
86
|
+
ignore?: string[]
|
|
87
|
+
/** Your own rules. */
|
|
88
|
+
custom?: MetadataRule[]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The values that the build checks need. */
|
|
93
|
+
export type BuildContext = {
|
|
94
|
+
/** The output directory of the build. */
|
|
95
|
+
dir: string
|
|
96
|
+
root?: URL
|
|
97
|
+
site?: string
|
|
98
|
+
base: string
|
|
99
|
+
/** The path patterns of the pages without checks. */
|
|
100
|
+
pages?: string[]
|
|
101
|
+
/** The rules to turn off, and the custom rules. */
|
|
102
|
+
checks: CheckOptions
|
|
103
|
+
/** sharp, for the size of the images. Without sharp, the checks skip the size. */
|
|
104
|
+
sharp?: (file: string) => { metadata(): Promise<{ width?: number; height?: number }> }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The Astro integration of `@mannisto/astro-metadata`. It gives the site values to the
|
|
109
|
+
* `<Metadata>` component, generates the favicons and the web app manifest, and checks
|
|
110
|
+
* the metadata of the built pages.
|
|
111
|
+
*/
|
|
112
|
+
export default function metadata(options?: MetadataOptions): AstroIntegration
|