@mannisto/astro-metadata 1.0.2 → 2.0.0-alpha.1

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.
Files changed (102) hide show
  1. package/README.md +427 -82
  2. package/package.json +25 -14
  3. package/src/assets/icons/LICENSE.md +35 -0
  4. package/src/assets/icons/binoculars.svg +1 -0
  5. package/src/assets/icons/caret-right.svg +1 -0
  6. package/src/assets/icons/check.svg +1 -0
  7. package/src/assets/icons/copy.svg +1 -0
  8. package/src/assets/icons/seal-check-duotone.svg +1 -0
  9. package/src/assets/icons/seal-question-duotone.svg +1 -0
  10. package/src/assets/icons/warning-circle-duotone.svg +1 -0
  11. package/src/assets/icons/warning-duotone.svg +1 -0
  12. package/src/assets/icons/x.svg +1 -0
  13. package/src/components/Metadata.astro +145 -0
  14. package/src/components/index.ts +2 -0
  15. package/src/integration.d.ts +112 -0
  16. package/src/integration.js +508 -0
  17. package/src/lib/checks.d.ts +70 -0
  18. package/src/lib/checks.js +193 -0
  19. package/src/lib/config.ts +111 -0
  20. package/src/lib/favicon-files.d.ts +29 -0
  21. package/src/lib/favicon-files.js +103 -0
  22. package/src/lib/favicon-image.ts +124 -0
  23. package/src/lib/favicon.ts +167 -0
  24. package/src/lib/head.d.ts +25 -0
  25. package/src/lib/head.js +141 -0
  26. package/src/lib/manifest.ts +126 -0
  27. package/src/lib/rules.d.ts +73 -0
  28. package/src/lib/rules.js +902 -0
  29. package/src/lib/schema.ts +208 -0
  30. package/src/lib/site.ts +72 -0
  31. package/src/lib/url.ts +79 -0
  32. package/src/routes/favicon.ts +14 -0
  33. package/src/routes/manifest.ts +18 -0
  34. package/src/runtime.ts +16 -0
  35. package/src/toolbar/app.ts +72 -0
  36. package/src/toolbar/assets.ts +81 -0
  37. package/src/toolbar/data.ts +282 -0
  38. package/src/toolbar/define.ts +7 -0
  39. package/src/toolbar/env.d.ts +10 -0
  40. package/src/toolbar/highlight.ts +83 -0
  41. package/src/toolbar/styles/shared.css +18 -0
  42. package/src/toolbar/styles/tokens.css +182 -0
  43. package/src/toolbar/toolbar-badge.ts +78 -0
  44. package/src/toolbar/ui/alert/alert.css +126 -0
  45. package/src/toolbar/ui/alert/alert.ts +102 -0
  46. package/src/toolbar/ui/badge/badge.css +41 -0
  47. package/src/toolbar/ui/badge/badge.ts +24 -0
  48. package/src/toolbar/ui/code-block/code-block.css +90 -0
  49. package/src/toolbar/ui/code-block/code-block.ts +68 -0
  50. package/src/toolbar/ui/color-swatch/color-swatch.css +15 -0
  51. package/src/toolbar/ui/color-swatch/color-swatch.ts +31 -0
  52. package/src/toolbar/ui/icon/icon.css +11 -0
  53. package/src/toolbar/ui/icon/icon.ts +46 -0
  54. package/src/toolbar/ui/image/image.css +18 -0
  55. package/src/toolbar/ui/image/image.ts +58 -0
  56. package/src/toolbar/ui/inline-code/inline-code.css +16 -0
  57. package/src/toolbar/ui/inline-code/inline-code.ts +41 -0
  58. package/src/toolbar/ui/section/section.css +88 -0
  59. package/src/toolbar/ui/section/section.ts +78 -0
  60. package/src/toolbar/ui/tab/tab.css +7 -0
  61. package/src/toolbar/ui/tab/tab.ts +47 -0
  62. package/src/toolbar/ui/tab-group/tab-group.css +42 -0
  63. package/src/toolbar/ui/tab-group/tab-group.ts +101 -0
  64. package/src/toolbar/ui/table/table.css +124 -0
  65. package/src/toolbar/ui/table/table.ts +155 -0
  66. package/src/toolbar/views/code-blocks.ts +35 -0
  67. package/src/toolbar/views/metadata-panel.css +101 -0
  68. package/src/toolbar/views/metadata-panel.ts +125 -0
  69. package/src/toolbar/views/overview-view.css +27 -0
  70. package/src/toolbar/views/overview-view.ts +401 -0
  71. package/src/toolbar/views/previews/discord.css +70 -0
  72. package/src/toolbar/views/previews/discord.ts +60 -0
  73. package/src/toolbar/views/previews/facebook.css +65 -0
  74. package/src/toolbar/views/previews/facebook.ts +36 -0
  75. package/src/toolbar/views/previews/google.css +75 -0
  76. package/src/toolbar/views/previews/google.ts +36 -0
  77. package/src/toolbar/views/previews/linkedin.css +58 -0
  78. package/src/toolbar/views/previews/linkedin.ts +34 -0
  79. package/src/toolbar/views/previews/page.ts +129 -0
  80. package/src/toolbar/views/previews/platform.ts +14 -0
  81. package/src/toolbar/views/previews/previews-view.css +37 -0
  82. package/src/toolbar/views/previews/previews-view.ts +52 -0
  83. package/src/toolbar/views/previews/slack.css +61 -0
  84. package/src/toolbar/views/previews/slack.ts +47 -0
  85. package/src/toolbar/views/previews/twitter.css +89 -0
  86. package/src/toolbar/views/previews/twitter.ts +57 -0
  87. package/src/toolbar/views/previews/whatsapp.css +88 -0
  88. package/src/toolbar/views/previews/whatsapp.ts +65 -0
  89. package/src/toolbar/views/raw-view.ts +41 -0
  90. package/index.ts +0 -31
  91. package/src/components/Canonical.astro +0 -11
  92. package/src/components/Description.astro +0 -9
  93. package/src/components/Favicon.astro +0 -96
  94. package/src/components/Head.astro +0 -94
  95. package/src/components/Keywords.astro +0 -9
  96. package/src/components/LanguageAlternates.astro +0 -18
  97. package/src/components/OpenGraph.astro +0 -75
  98. package/src/components/Robots.astro +0 -25
  99. package/src/components/Schema.astro +0 -18
  100. package/src/components/Title.astro +0 -13
  101. package/src/components/Twitter.astro +0 -27
  102. package/src/lib/metadata.ts +0 -77
@@ -1,9 +0,0 @@
1
- ---
2
- export type Props = {
3
- value?: string[]
4
- }
5
-
6
- const { value = [] } = Astro.props
7
- ---
8
-
9
- {value.length > 0 && <meta name="keywords" content={value.join(", ")} />}
@@ -1,18 +0,0 @@
1
- ---
2
- export type LanguageAlternate = {
3
- href: string
4
- hreflang: string
5
- }
6
-
7
- export type Props = {
8
- alternates: LanguageAlternate[]
9
- }
10
-
11
- const { alternates } = Astro.props
12
- ---
13
-
14
- {
15
- alternates.map((alternate) => (
16
- <link rel="alternate" href={alternate.href} hreflang={alternate.hreflang} />
17
- ))
18
- }
@@ -1,75 +0,0 @@
1
- ---
2
- export type OpenGraphImage = {
3
- url: string
4
- secureUrl?: string
5
- type?: string
6
- alt?: string
7
- width?: number
8
- height?: number
9
- }
10
-
11
- export type OpenGraphVideo = {
12
- url: string
13
- secureUrl?: string
14
- type?: string
15
- width?: number
16
- height?: number
17
- }
18
-
19
- export type OpenGraphAudio = {
20
- url: string
21
- secureUrl?: string
22
- type?: string
23
- }
24
-
25
- export type Props = {
26
- title?: string
27
- description?: string
28
- url?: string
29
- type?: string
30
- siteName?: string
31
- locale?: string
32
- localeAlternate?: string[]
33
- image?: OpenGraphImage
34
- video?: OpenGraphVideo
35
- audio?: OpenGraphAudio
36
- }
37
-
38
- const {
39
- title,
40
- description,
41
- url,
42
- type = "website",
43
- siteName,
44
- locale,
45
- localeAlternate,
46
- image,
47
- video,
48
- audio,
49
- } = Astro.props
50
- ---
51
-
52
- {title && <meta property="og:title" content={title} />}
53
- {description && <meta property="og:description" content={description} />}
54
- {url && <meta property="og:url" content={url} />}
55
- {type && <meta property="og:type" content={type} />}
56
- {siteName && <meta property="og:site_name" content={siteName} />}
57
- {locale && <meta property="og:locale" content={locale} />}
58
- {localeAlternate?.map((loc: string) => <meta property="og:locale:alternate" content={loc} />)}
59
-
60
- {image?.url && <meta property="og:image" content={image.url} />}
61
- {image?.secureUrl && <meta property="og:image:secure_url" content={image.secureUrl} />}
62
- {image?.type && <meta property="og:image:type" content={image.type} />}
63
- {image?.alt && <meta property="og:image:alt" content={image.alt} />}
64
- {image?.width && <meta property="og:image:width" content={String(image.width)} />}
65
- {image?.height && <meta property="og:image:height" content={String(image.height)} />}
66
-
67
- {video?.url && <meta property="og:video" content={video.url} />}
68
- {video?.secureUrl && <meta property="og:video:secure_url" content={video.secureUrl} />}
69
- {video?.type && <meta property="og:video:type" content={video.type} />}
70
- {video?.width && <meta property="og:video:width" content={String(video.width)} />}
71
- {video?.height && <meta property="og:video:height" content={String(video.height)} />}
72
-
73
- {audio?.url && <meta property="og:audio" content={audio.url} />}
74
- {audio?.secureUrl && <meta property="og:audio:secure_url" content={audio.secureUrl} />}
75
- {audio?.type && <meta property="og:audio:type" content={audio.type} />}
@@ -1,25 +0,0 @@
1
- ---
2
- export type Props = {
3
- index?: boolean
4
- follow?: boolean
5
- archive?: boolean
6
- snippet?: boolean
7
- extra?: string
8
- }
9
-
10
- const { index = true, follow = true, archive = true, snippet = true, extra } = Astro.props
11
-
12
- // Combine the directives into a comma separated string,
13
- // for example: "index, follow, noarchive, nosnippet"
14
- const directives = [
15
- index ? "index" : "noindex",
16
- follow ? "follow" : "nofollow",
17
- !archive ? "noarchive" : null,
18
- !snippet ? "nosnippet" : null,
19
- extra,
20
- ]
21
- .filter(Boolean)
22
- .join(", ")
23
- ---
24
-
25
- <meta name="robots" content={directives} />
@@ -1,18 +0,0 @@
1
- ---
2
- export type Props = {
3
- schema: Record<string, unknown>
4
- }
5
-
6
- const { schema } = Astro.props
7
-
8
- // Escape the characters that can end the script tag or break the JavaScript parser.
9
- // A value such as "</script>" in the schema then stays inside the JSON.
10
- const json = JSON.stringify(schema)
11
- .replace(/</g, "\\u003c")
12
- .replace(/>/g, "\\u003e")
13
- .replace(/&/g, "\\u0026")
14
- .replace(/\u2028/g, "\\u2028")
15
- .replace(/\u2029/g, "\\u2029")
16
- ---
17
-
18
- <script is:inline type="application/ld+json" set:html={json} />
@@ -1,13 +0,0 @@
1
- ---
2
- export type Props = {
3
- value: string
4
- template?: `${string}%s${string}`
5
- }
6
-
7
- const { value, template = "%s" } = Astro.props
8
-
9
- // A replacer function keeps "$&" and other "$" patterns in the title as text
10
- const title = template.replace("%s", () => value)
11
- ---
12
-
13
- <title>{title}</title>
@@ -1,27 +0,0 @@
1
- ---
2
- export type Props = {
3
- title?: string
4
- description?: string
5
- /**
6
- * @deprecated X does not read `twitter:url`. The component ignores this value.
7
- */
8
- url?: string
9
- card?: "summary" | "summary_large_image" | "player" | "app"
10
- site?: string
11
- creator?: string
12
- image?: {
13
- url: string
14
- alt?: string
15
- }
16
- }
17
-
18
- const { title, description, card = "summary_large_image", site, creator, image } = Astro.props
19
- ---
20
-
21
- {card && <meta name="twitter:card" content={card} />}
22
- {title && <meta name="twitter:title" content={title} />}
23
- {description && <meta name="twitter:description" content={description} />}
24
- {image?.url && <meta name="twitter:image" content={image.url} />}
25
- {image?.alt && <meta name="twitter:image:alt" content={image.alt} />}
26
- {site && <meta name="twitter:site" content={site} />}
27
- {creator && <meta name="twitter:creator" content={creator} />}
@@ -1,77 +0,0 @@
1
- import type { ComponentProps } from "astro/types"
2
-
3
- import type Head from "../components/Head.astro"
4
-
5
- let store: Partial<ComponentProps<typeof Head>> = {}
6
-
7
- /**
8
- * Metadata manages page-level head properties.
9
- * Call set() in your page, then resolve() in your layout.
10
- */
11
- export const Metadata = {
12
- /**
13
- * Replace the current metadata store with new values.
14
- *
15
- * @param values - The head properties to store.
16
- */
17
- set(values: Partial<ComponentProps<typeof Head>>) {
18
- store = values
19
- },
20
-
21
- /**
22
- * Return the current metadata store.
23
- *
24
- * @returns The current head properties.
25
- */
26
- get(): Partial<ComponentProps<typeof Head>> {
27
- return store
28
- },
29
-
30
- /**
31
- * Merge stored values over the provided defaults.
32
- * Use this in your layout to apply page-level overrides.
33
- *
34
- * @param defaults - The default head properties from your layout.
35
- * @returns The merged head properties.
36
- */
37
- resolve(defaults: Partial<ComponentProps<typeof Head>>): Partial<ComponentProps<typeof Head>> {
38
- return { ...defaults, ...store }
39
- },
40
-
41
- get title() {
42
- return store.title
43
- },
44
- get titleTemplate() {
45
- return store.titleTemplate
46
- },
47
- get description() {
48
- return store.description
49
- },
50
- get canonical() {
51
- return store.canonical
52
- },
53
- get keywords() {
54
- return store.keywords
55
- },
56
- get image() {
57
- return store.image
58
- },
59
- get robots() {
60
- return store.robots
61
- },
62
- get openGraph() {
63
- return store.openGraph
64
- },
65
- get twitter() {
66
- return store.twitter
67
- },
68
- get favicon() {
69
- return store.favicon
70
- },
71
- get schema() {
72
- return store.schema
73
- },
74
- get languageAlternates() {
75
- return store.languageAlternates
76
- },
77
- }