Complete residential site build with Docker Compose & Gitea Actions deployment
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Jonas Schumacher
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+238
@@ -0,0 +1,238 @@
|
||||

|
||||
|
||||
# 🚀 Astro SEO
|
||||
|
||||
This [Astro](https://astro.build/) component makes it easy to add tags that are
|
||||
relevant for search engine optimization (SEO) to your pages.
|
||||
|
||||
The ultimate goal is to make this the one-stop shop for most of your SEO needs when developing Astro sites.
|
||||
|
||||
Pull requests and/or feature requests are very welcome!
|
||||
|
||||
## Installation
|
||||
|
||||
To install Astro SEO, run the following command in your terminal:
|
||||
|
||||
```bash
|
||||
npm install astro-seo
|
||||
```
|
||||
|
||||
or if you use yarn:
|
||||
|
||||
```bash
|
||||
yarn add astro-seo
|
||||
```
|
||||
|
||||
## How To Use
|
||||
|
||||
In any of your Astro pages, import Astro SEO and then use the component inside
|
||||
the `<head>` section of your HTML:
|
||||
|
||||
```astro
|
||||
---
|
||||
import { SEO } from "astro-seo";
|
||||
---
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<SEO
|
||||
title="A Very Descriptive Title"
|
||||
description="A heavily optimized description full of well-researched keywords."
|
||||
openGraph={{
|
||||
basic: {
|
||||
title: "A Very Descriptive Title",
|
||||
type: "A type.",
|
||||
image: "https://user-images.githubusercontent.com/5182256/131216951-8f74f425-f775-463d-a11b-0e01ad9fce8d.png",
|
||||
}
|
||||
}}
|
||||
twitter={{
|
||||
creator: "@jonasmerlins1"
|
||||
}}
|
||||
extend={{
|
||||
// extending the default link tags
|
||||
link: [{ rel: "icon", href: "/favicon.ico" }],
|
||||
// extending the default meta tags
|
||||
meta: [
|
||||
{
|
||||
name: "twitter:image",
|
||||
content: "https://user-images.githubusercontent.com/5182256/131216951-8f74f425-f775-463d-a11b-0e01ad9fce8d.png",
|
||||
},
|
||||
{ name: "twitter:title", content: "Tinker Tailor Soldier Spy" },
|
||||
{ name: "twitter:description", content: "Agent" },
|
||||
],
|
||||
}}
|
||||
/>
|
||||
// ... rest of <head>
|
||||
</head>
|
||||
<body> // ... body </body>
|
||||
</html>
|
||||
```
|
||||
|
||||
## Using with Layouts
|
||||
|
||||
A common Astro pattern is to have a Layout component that wraps your pages and contains the `<head>` element. To pass SEO properties from your pages to the layout, use Astro's standard props pattern:
|
||||
|
||||
**Layout.astro:**
|
||||
```astro
|
||||
---
|
||||
import { SEO } from "astro-seo";
|
||||
|
||||
interface Props {
|
||||
title: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
const { title, description } = Astro.props;
|
||||
---
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<SEO
|
||||
title={title}
|
||||
description={description}
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<slot />
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
**index.astro (your page):**
|
||||
```astro
|
||||
---
|
||||
import Layout from "../layouts/Layout.astro";
|
||||
---
|
||||
|
||||
<Layout title="Homepage" description="Welcome to my site">
|
||||
<h1>Hello!</h1>
|
||||
</Layout>
|
||||
```
|
||||
|
||||
This pattern allows each page to define its own SEO values while keeping the `<SEO>` component in a single, reusable layout. For more information on layouts and passing props between components, see the [Astro Layouts documentation](https://docs.astro.build/en/basics/layouts/).
|
||||
|
||||
## Supported Props
|
||||
|
||||
Propname | Type | Description
|
||||
------------ | ------------- | -------------
|
||||
title | string | The title of the page.
|
||||
titleTemplate | string | Provide a title template to keep a consistent title style. `%s — Astro SEO`, `%s` will be replaced with your title, e.g. `Homepage — Astro SEO`
|
||||
titleDefault | string | Fallback title that is used if no title is provided.
|
||||
description | string | Text that gives a concise description of what your page is about.
|
||||
canonical | string | Prevent duplicate content issues by specifying the "canonical" or "preferred" url of a web page. If you don't define this, `Astro.url.href` will be used as the default value.
|
||||
noindex | boolean | Set this to true if you don't want search engines to index your page. Since this is an SEO component, this gets set to `false` by default. This way, indexing is strictly opt-out.
|
||||
nofollow | boolean | Set this to true if you don't want search engines to follow links on your page. Since this is an SEO component, this gets set to `false` by default. This way, following links is strictly opt-out.
|
||||
noarchive | boolean | Set this to true if you don't want search engines to show a cached link for your page.
|
||||
nocache | boolean | Set this to true if you don't want search engines to cache your page content.
|
||||
robotsExtras | string | Additional robots directives not covered by the boolean options above. Useful for directives like `max-snippet:-1`, `max-image-preview:large`, `max-video-preview:-1`. Pass as a comma-separated string, e.g. `"max-snippet:-1, max-image-preview:large"`.
|
||||
charset | string | Set the charset of the document. In almost all cases this should be UTF-8.
|
||||
languageAlternates | Array<{ href: string; hrefLang: string }> | List of language alternates for the page.
|
||||
openGraph.basic.title | string | Set the title Open Graph should use. __In most situations, this should be _different_ from the value of the `title` prop.__ See [this tweet](https://twitter.com/jon_neal/status/1428721238071988237) to gain an understanding of the difference between the two. If you define this, you must define two other OG basic properties as well: `type` and `image`. ([Learn more.](https://ogp.me/#metadata))
|
||||
openGraph.basic.type | string | Set the [type](https://ogp.me/#types) Open Graph should use. If you define this, you must define two other OG basic properties as well: `title` and `image`. ([Learn more.](https://ogp.me/#metadata))
|
||||
openGraph.basic.image | string | URL of the image that should be used in social media previews. If you define this, you must define two other OG basic properties as well: `title` and `type`. ([Learn more.](https://ogp.me/#metadata))
|
||||
openGraph.basic.url | string | The canonical URL of your object that will be used as its permanent ID in the graph. Most likely either the url of the page or its canonical url (see above). If you define this, you must define the other 3 OG basic properties as well: `title`, `type` and `image`. ([Learn more.](https://ogp.me/#metadata)). If you define the other 3 OG basic properties but don't define this, `Astro.request.url.href` will be used as the default value.
|
||||
openGraph.optional.audio | string | A URL to an audio file to accompany this object.
|
||||
openGraph.optional.description | string | A one to two sentence description of your object.
|
||||
openGraph.optional.determiner | string | The word that appears before this object's title in a sentence. An enum of (a, an, the, "", auto). If auto is chosen, the consumer of your data should chose between "a" or "an". Default is "" (blank).
|
||||
openGraph.optional.locale | string | The locale these tags are marked up in. Of the format language_TERRITORY. Default is en_US.
|
||||
openGraph.optional.localeAlternate | Array<string> | An array of other locales this page is available in.
|
||||
openGraph.optional.siteName | string | If your object is part of a larger web site, the name which should be displayed for the overall site. e.g., "IMDb".
|
||||
openGraph.optional.video | string | A URL to a video file that complements this object.
|
||||
openGraph.image.url | string | For now, setting this is ignored. This is done because `og:image:url` is supposed to be identical to `og:image`. If you have a use case where it makes sense for these to be different, please feel free to contact me, and tell me about it and I will consider adding it. Until then, in the interest of enforcing best practices, the value of this property will be ignored and `og:image:url` set to the value of `openGraph.basic.image`.
|
||||
openGraph.image.secureUrl | string | Sets `og:image:secure_url`: An alternate url to use if the webpage requires HTTPS.
|
||||
openGraph.image.type | string | Sets `og:image:type`. A MIME type for the image. e.g. "image/jpeg"
|
||||
openGraph.image.width | number | Sets `og:image:width`. The number of pixels wide.
|
||||
openGraph.image.height | number | Sets `og:image:height`. The number of pixels high.
|
||||
openGraph.image.alt | string | Sets `og:image:alt`. A description of what is in the image (not a caption). __If the page specifies `openGraph.basic.image` it should specify `openGraph.image.alt`__.
|
||||
openGraph.article.publishedTime | string | Sets `article:published_time`. The date the article was published. Must be a ISO 8601 DateTime string.
|
||||
openGraph.article.modifiedTime | string | Sets `article:modified_time`. The date the article was last modified. Must be a ISO 8601 DateTime string.
|
||||
openGraph.article.expirationTime | string | Sets `article:expiration_time`. The date the article will no longer be relevant. Must be a ISO 8601 DateTime string.
|
||||
openGraph.article.authors | string[] | Sets `article:author`. The author(s) of the article, if it's only one, pass an array with one entry. If there are multiple, multiple tags with descending relevance will be created.
|
||||
openGraph.article.section | string | Sets `article:section`. A high-level section name. E.g. Technology
|
||||
openGraph.article.tags | string[] | Sets `article:tag`. Tag words associated with this article. If it's only one, pass an array with one entry. If there are multiple, multiple tags with descending relevance will be created.
|
||||
twitter.card | TwitterCardType (string) | Sets `twitter:card`. The card type. Must be one of “summary”, “summary_large_image”, “app”, or “player”.
|
||||
twitter.site | string | Sets `twitter:site`. (Twitter) @username for the website used in the card footer.
|
||||
twitter.creator | string | Sets `twitter:creator`. (Twitter) @username for the content creator / author.
|
||||
twitter.title | string | Sets `twitter:title`. Title of the page or article (equivalent to Open Graph's og:title).
|
||||
twitter.image | string | Sets `twitter:image`. Full link to the image you want to use for the page (equivalent to Open Graph's og:image).
|
||||
twitter.imageAlt | string | Sets `twitter:image:alt`. A description of what is in the image (not a caption). __If the page specifies `twitter.image` it should specify `twitter.imageAlt`__.
|
||||
twitter.description | string | Sets `twitter:description`. A one to two sentence description of your object.
|
||||
extend.link | Array<Link extends HTMLLinkElement { prefetch: boolean; }> | An array of free-form `<link>` you'd like to define.
|
||||
extend.meta | Array<Meta extends HTMLMetaElement { property: string; }> | An array of free-form `<meta>` tags you'd like to define.
|
||||
|
||||
## Extending Astro SEO
|
||||
|
||||
With the `v0.3.14` release, you can now define any `<meta>` and `<link>` tag you want using the `extend` prop. For example :
|
||||
|
||||
```js
|
||||
<SEO
|
||||
extend={{
|
||||
// extending the default link tags
|
||||
link: [{ rel: "icon", href: "/favicon.ico" }],
|
||||
// extending the default meta tags
|
||||
meta: [
|
||||
{
|
||||
name: "twitter:image",
|
||||
content:
|
||||
"https://user-images.githubusercontent.com/5182256/131216951-8f74f425-f775-463d-a11b-0e01ad9fce8d.png",
|
||||
},
|
||||
{ name: "twitter:title", content: "Tinker Tailor Soldier Spy" },
|
||||
{ name: "twitter:description", content: "Agent" },
|
||||
],
|
||||
}}
|
||||
/>
|
||||
```
|
||||
|
||||
## Open Graph
|
||||
|
||||
Open Graph properties are passed as one object to the prop `openGraph`. The structure of this object is modeled after the [Open Graph documentation](https://ogp.me/) itself. That means it uses nested objects to differentiate between basic and optional properties, as well as object specific ones. __If you pass an openGraph config, you _must_ define all 4 of the basic properties (`title`, `type`, `image` and `url`).__ The optional properties are all ... well, optional.
|
||||
|
||||
```typescript
|
||||
// TypeScript interface of openGraph prop
|
||||
openGraph?: {
|
||||
basic: {
|
||||
title: string;
|
||||
type: string;
|
||||
image: string;
|
||||
url: string;
|
||||
},
|
||||
optional?: {
|
||||
audio?: string;
|
||||
description?: string;
|
||||
determiner?: string;
|
||||
locale?: string;
|
||||
localeAlternate?: Array<string>;
|
||||
siteName?: string;
|
||||
video?: string;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Goals
|
||||
|
||||
Our first goal for this project is to support the most-used tags that are
|
||||
relevant for SEO. That includes the most-used open graph tags.
|
||||
|
||||
After that comes feature-parity with Next SEO. After _that_ ... we'll see.
|
||||
|
||||
## What does this component do, exactly?
|
||||
|
||||
There's certainly no magic to what Astro SEO does. Basically, it bundles the
|
||||
creation of regular SEO-relevant HTML tags inside one component that you can
|
||||
then use inside your page's `<head>` tag.
|
||||
|
||||
The translation between props and tags is pretty direct and almost 1:1. After
|
||||
building, there probably won't be anything you wouldn't have written yourself.
|
||||
The idea is to surface the options that exist in a central place and adhere to
|
||||
best practices where it's theoretically possible not to. __If you want to see
|
||||
how the sausage gets made, there's only one place you will have to check__:
|
||||
`/src/SEO.astro`
|
||||
|
||||
If you want, you can view Astro SEO as a checklist, so you don't forget a tag.
|
||||
Or maybe also as an educational tool, to see which options exist in the first
|
||||
place.
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
Astro SEO is _heavily_ inspired by [Next SEO](https://github.com/garmeeh/next-seo)
|
||||
and all the amazing work Gary is doing developing it. Thanks Gary! ❤️
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from "./src";
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "astro-seo",
|
||||
"version": "1.1.0",
|
||||
"description": "Makes it easy to add SEO relevant tags to your Astro app.",
|
||||
"homepage": "https://github.com/jonasmerlin/astro-seo#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonasmerlin/astro-seo/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jonasmerlin/astro-seo"
|
||||
},
|
||||
"files": [
|
||||
"index.ts",
|
||||
"src/index.ts",
|
||||
"src/SEO.astro",
|
||||
"src/components"
|
||||
],
|
||||
"exports": "./index.ts",
|
||||
"keywords": [
|
||||
"astro-component",
|
||||
"seo"
|
||||
],
|
||||
"author": "Jonas Schumacher",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"cypress:open": "cypress open",
|
||||
"dev": "astro dev",
|
||||
"build": "astro check && tsc --noEmit && astro build",
|
||||
"start": "astro preview",
|
||||
"format": "prettier -w ./src",
|
||||
"check:format": "prettier -c ./src",
|
||||
"release": "standard-version",
|
||||
"check": "astro check"
|
||||
},
|
||||
"devDependencies": {
|
||||
"astro": "^5.16.0",
|
||||
"cypress": "^13.0.0",
|
||||
"prettier": "^3.0.3",
|
||||
"prettier-plugin-astro": "^0.12.0",
|
||||
"standard-version": "^9.5.0",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/check": "^0.9.0"
|
||||
}
|
||||
}
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
---
|
||||
import OpenGraphArticleTags from "./components/OpenGraphArticleTags.astro";
|
||||
import OpenGraphBasicTags from "./components/OpenGraphBasicTags.astro";
|
||||
import OpenGraphImageTags from "./components/OpenGraphImageTags.astro";
|
||||
import OpenGraphOptionalTags from "./components/OpenGraphOptionalTags.astro";
|
||||
import ExtendedTags from "./components/ExtendedTags.astro";
|
||||
import TwitterTags from "./components/TwitterTags.astro";
|
||||
import LanguageAlternatesTags from "./components/LanguageAlternatesTags.astro";
|
||||
|
||||
export type TwitterCardType = "summary" | "summary_large_image" | "app" | "player";
|
||||
|
||||
export interface Link extends Omit<HTMLLinkElement, 'sizes'> {
|
||||
prefetch: boolean;
|
||||
crossorigin: string;
|
||||
sizes: string;
|
||||
}
|
||||
|
||||
export interface Meta extends HTMLMetaElement {
|
||||
property: string;
|
||||
}
|
||||
|
||||
export interface Props {
|
||||
title?: string;
|
||||
titleTemplate?: string;
|
||||
titleDefault?: string;
|
||||
charset?: string;
|
||||
description?: string;
|
||||
canonical?: URL | string;
|
||||
nofollow?: boolean;
|
||||
noindex?: boolean;
|
||||
noarchive?: boolean;
|
||||
nocache?: boolean;
|
||||
robotsExtras?: string;
|
||||
languageAlternates?: {
|
||||
href: URL | string;
|
||||
hrefLang: string;
|
||||
}[];
|
||||
openGraph?: {
|
||||
basic: {
|
||||
title: string;
|
||||
type: string;
|
||||
image: string;
|
||||
url?: URL | string;
|
||||
};
|
||||
optional?: {
|
||||
audio?: string;
|
||||
description?: string;
|
||||
determiner?: string;
|
||||
locale?: string;
|
||||
localeAlternate?: string[];
|
||||
siteName?: string;
|
||||
video?: string;
|
||||
};
|
||||
image?: {
|
||||
url?: URL | string;
|
||||
secureUrl?: URL | string;
|
||||
type?: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
alt?: string;
|
||||
};
|
||||
article?: {
|
||||
publishedTime?: string;
|
||||
modifiedTime?: string;
|
||||
expirationTime?: string;
|
||||
authors?: string[];
|
||||
section?: string;
|
||||
tags?: string[];
|
||||
};
|
||||
};
|
||||
twitter?: {
|
||||
card?: TwitterCardType;
|
||||
site?: string;
|
||||
creator?: string;
|
||||
title?: string;
|
||||
description?: string;
|
||||
image?: URL | string;
|
||||
imageAlt?: string;
|
||||
};
|
||||
extend?: {
|
||||
link?: Partial<Link>[];
|
||||
meta?: Partial<Meta>[];
|
||||
};
|
||||
removeTrailingSlashForRoot?: boolean;
|
||||
surpressWarnings?: boolean;
|
||||
}
|
||||
|
||||
Astro.props.surpressWarnings = true;
|
||||
|
||||
function validateProps(props: Props) {
|
||||
if (props.openGraph) {
|
||||
if (
|
||||
!props.openGraph.basic ||
|
||||
(props.openGraph.basic.title ?? undefined) == undefined ||
|
||||
(props.openGraph.basic.type ?? undefined) == undefined ||
|
||||
(props.openGraph.basic.image ?? undefined) == undefined
|
||||
) {
|
||||
throw new Error(
|
||||
"If you pass the openGraph prop, you have to at least define the title, type, and image basic properties!"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (props.title && props.openGraph?.basic.title) {
|
||||
if (props.title == props.openGraph.basic.title && !props.surpressWarnings) {
|
||||
console.warn(
|
||||
"WARNING(astro-seo): You passed the same value to `title` and `openGraph.optional.title`. This is most likely not what you want. See docs for more."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
props.openGraph?.basic?.image &&
|
||||
!props.openGraph?.image?.alt &&
|
||||
!props.surpressWarnings
|
||||
) {
|
||||
console.warn(
|
||||
"WARNING(astro-seo): You defined `openGraph.basic.image`, but didn't define `openGraph.image.alt`. This is strongly discouraged.'"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
validateProps(Astro.props);
|
||||
|
||||
let updatedTitle = "";
|
||||
|
||||
if (Astro.props.title) {
|
||||
updatedTitle = Astro.props.title;
|
||||
if (Astro.props.titleTemplate) {
|
||||
updatedTitle = Astro.props.titleTemplate.replace(/%s/g, updatedTitle);
|
||||
}
|
||||
} else if (Astro.props.titleDefault) {
|
||||
updatedTitle = Astro.props.titleDefault;
|
||||
}
|
||||
|
||||
const baseUrl = Astro.site ?? Astro.url;
|
||||
const defaultCanonicalUrl = new URL(Astro.url.pathname + Astro.url.search, baseUrl);
|
||||
|
||||
// When removeTrailingSlashForRoot is true and we're at the root path, remove the trailing slash.
|
||||
// This is because new URL("/", base) always produces a trailing slash (e.g. "https://example.com/"),
|
||||
// but users with Astro's trailingSlash: 'never' expect "https://example.com" without it.
|
||||
// For SEO purposes these are equivalent (search engines treat them the same), but this option
|
||||
// allows matching the 'never' expectation. Default is false to preserve existing behavior.
|
||||
// See: https://github.com/jonasmerlin/astro-seo/issues/101
|
||||
const shouldRemoveTrailingSlash = Astro.props.removeTrailingSlashForRoot && Astro.url.pathname === '/';
|
||||
const canonicalHref = shouldRemoveTrailingSlash
|
||||
? defaultCanonicalUrl.origin + defaultCanonicalUrl.search
|
||||
: defaultCanonicalUrl.href;
|
||||
---
|
||||
|
||||
{updatedTitle ? <title set:html={updatedTitle} /> : null}
|
||||
|
||||
{Astro.props.charset ? <meta charset={Astro.props.charset} /> : null}
|
||||
|
||||
<link rel="canonical" href={Astro.props.canonical || canonicalHref} />
|
||||
|
||||
{
|
||||
Astro.props.description ? (
|
||||
<meta name="description" content={Astro.props.description} />
|
||||
) : null
|
||||
}
|
||||
|
||||
<meta
|
||||
name="robots"
|
||||
content={`${Astro.props.noindex ? "noindex" : "index"}, ${
|
||||
Astro.props.nofollow ? "nofollow" : "follow"
|
||||
}${Astro.props.noarchive ? ", noarchive" : ""}${Astro.props.nocache ? ", nocache" : ""}${Astro.props.robotsExtras ? `, ${Astro.props.robotsExtras}` : ""}`}
|
||||
/>
|
||||
|
||||
{Astro.props.openGraph && <OpenGraphBasicTags {...Astro.props} />}
|
||||
{Astro.props.openGraph?.optional && <OpenGraphOptionalTags {...Astro.props} />}
|
||||
{Astro.props.openGraph?.image && <OpenGraphImageTags {...Astro.props} />}
|
||||
{Astro.props.openGraph?.article && <OpenGraphArticleTags {...Astro.props} />}
|
||||
{Astro.props.twitter && <TwitterTags {...Astro.props} />}
|
||||
{Astro.props.extend && <ExtendedTags {...Astro.props} />}
|
||||
{Astro.props.languageAlternates && <LanguageAlternatesTags {...Astro.props} />}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
---
|
||||
import type { HTMLAttributes } from "astro/types";
|
||||
|
||||
const { props } = Astro;
|
||||
|
||||
type Link = HTMLAttributes<"link">;
|
||||
---
|
||||
|
||||
{props.extend.link?.map((attributes: Link) => <link {...attributes} />)}
|
||||
{
|
||||
props.extend.meta?.map(({ content, httpEquiv, media, name, property }) => (
|
||||
<meta
|
||||
name={name}
|
||||
property={property}
|
||||
content={content}
|
||||
http-equiv={httpEquiv}
|
||||
media={media}
|
||||
/>
|
||||
))
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
---
|
||||
interface LanguageAlternate {
|
||||
href: URL | string;
|
||||
hrefLang: string;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
languageAlternates?: LanguageAlternate[];
|
||||
}
|
||||
|
||||
const { languageAlternates } = Astro.props;
|
||||
---
|
||||
|
||||
{
|
||||
languageAlternates.map((alternate: LanguageAlternate) => (
|
||||
<link rel="alternate" hreflang={alternate.hrefLang} href={alternate.href} />
|
||||
))
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
---
|
||||
const { publishedTime, modifiedTime, expirationTime, authors, section, tags } =
|
||||
Astro.props.openGraph.article;
|
||||
---
|
||||
|
||||
{
|
||||
publishedTime ? (
|
||||
<meta property="article:published_time" content={publishedTime} />
|
||||
) : null
|
||||
}
|
||||
{
|
||||
modifiedTime ? (
|
||||
<meta property="article:modified_time" content={modifiedTime} />
|
||||
) : null
|
||||
}
|
||||
{
|
||||
expirationTime ? (
|
||||
<meta property="article:expiration_time" content={expirationTime} />
|
||||
) : null
|
||||
}
|
||||
{
|
||||
authors
|
||||
? authors.map((author: string) => (
|
||||
<meta property="article:author" content={author} />
|
||||
))
|
||||
: null
|
||||
}
|
||||
{section ? <meta property="article:section" content={section} /> : null}
|
||||
{
|
||||
tags
|
||||
? tags.map((tag: string) => <meta property="article:tag" content={tag} />)
|
||||
: null
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
---
|
||||
const { openGraph } = Astro.props;
|
||||
---
|
||||
|
||||
<meta property="og:title" content={openGraph.basic.title} />
|
||||
<meta property="og:type" content={openGraph.basic.type} />
|
||||
<meta property="og:image" content={openGraph.basic.image} />
|
||||
<meta property="og:url" content={openGraph.basic.url || Astro.url.href} />
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
---
|
||||
const { image } = Astro.props.openGraph.basic;
|
||||
const { secureUrl, type, width, height, alt } = Astro.props.openGraph.image;
|
||||
---
|
||||
|
||||
<meta property="og:image:url" content={image} />
|
||||
{secureUrl ? <meta property="og:image:secure_url" content={secureUrl} /> : null}
|
||||
{type ? <meta property="og:image:type" content={type} /> : null}
|
||||
{width ? <meta property="og:image:width" content={width} /> : null}
|
||||
{height ? <meta property="og:image:height" content={height} /> : null}
|
||||
{alt ? <meta property="og:image:alt" content={alt} /> : null}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
---
|
||||
const { optional } = Astro.props.openGraph;
|
||||
---
|
||||
|
||||
{optional.audio ? <meta property="og:audio" content={optional.audio} /> : null}
|
||||
{
|
||||
optional.description ? (
|
||||
<meta property="og:description" content={optional.description} />
|
||||
) : null
|
||||
}
|
||||
{
|
||||
optional.determiner ? (
|
||||
<meta property="og:determiner" content={optional.determiner} />
|
||||
) : null
|
||||
}
|
||||
{
|
||||
optional.locale ? (
|
||||
<meta property="og:locale" content={optional.locale} />
|
||||
) : null
|
||||
}
|
||||
{
|
||||
optional.localeAlternate?.map((locale: string) => (
|
||||
<meta property="og:locale:alternate" content={locale} />
|
||||
))
|
||||
}
|
||||
{
|
||||
optional.siteName ? (
|
||||
<meta property="og:site_name" content={optional.siteName} />
|
||||
) : null
|
||||
}
|
||||
{optional.video ? <meta property="og:video" content={optional.video} /> : null}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
---
|
||||
const { card, site, title, creator, description, image, imageAlt } =
|
||||
Astro.props.twitter;
|
||||
---
|
||||
|
||||
{card ? <meta name="twitter:card" content={card} /> : null}
|
||||
{site ? <meta name="twitter:site" content={site} /> : null}
|
||||
{title ? <meta name="twitter:title" content={title} /> : null}
|
||||
{image ? <meta name="twitter:image" content={image} /> : null}
|
||||
{imageAlt ? <meta name="twitter:image:alt" content={imageAlt} /> : null}
|
||||
{description ? <meta name="twitter:description" content={description} /> : null}
|
||||
{creator ? <meta name="twitter:creator" content={creator} /> : null}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// @ts-ignore
|
||||
export { default as SEO } from "./SEO.astro";
|
||||
|
||||
// @ts-ignore
|
||||
export * from "./SEO.astro";
|
||||
|
||||
// @ts-ignore
|
||||
import { Props } from "./SEO.astro";
|
||||
|
||||
// @ts-ignore
|
||||
export type SEOProps = Props;
|
||||
Reference in New Issue
Block a user