Skip to content

Commit

Permalink
feat(plugin-seo): add seo plugin (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Jan 31, 2024
1 parent b0b2aa4 commit 8a999c5
Show file tree
Hide file tree
Showing 55 changed files with 2,788 additions and 3 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Expand Up @@ -28,6 +28,7 @@
"frontmatter",
"globby",
"gtag",
"jsonld",
"mdit",
"nord",
"nprogress",
Expand Down
2 changes: 1 addition & 1 deletion docs/.vuepress/configs/navbar/en.ts
Expand Up @@ -39,7 +39,7 @@ export const navbarEn: NavbarConfig = [
},
{
text: 'SEO',
children: ['/plugins/sitemap'],
children: ['/plugins/seo/', '/plugins/sitemap/'],
},
{
text: 'Syntax Highlighting',
Expand Down
2 changes: 1 addition & 1 deletion docs/.vuepress/configs/navbar/zh.ts
Expand Up @@ -39,7 +39,7 @@ export const navbarZh: NavbarConfig = [
},
{
text: '搜索引擎增强',
children: ['/zh/plugins/sitemap'],
children: ['/zh/plugins/seo/', '/zh/plugins/sitemap/'],
},
{
text: '语法高亮',
Expand Down
5 changes: 5 additions & 0 deletions docs/.vuepress/configs/sidebar/en.ts
Expand Up @@ -41,6 +41,11 @@ export const sidebarEn: SidebarConfig = {
{
text: 'SEO',
children: [
{
text: 'SEO',
link: '/plugins/seo/',
children: ['/plugins/seo/guide', '/plugins/seo/config'],
},
{
text: 'Sitemap',
link: '/plugins/sitemap/',
Expand Down
5 changes: 5 additions & 0 deletions docs/.vuepress/configs/sidebar/zh.ts
Expand Up @@ -41,6 +41,11 @@ export const sidebarZh: SidebarConfig = {
{
text: '搜索引擎增强',
children: [
{
text: '搜索引擎增强',
link: '/zh/plugins/seo/',
children: ['/zh/plugins/seo/guide', '/zh/plugins/seo/config'],
},
{
text: '站点地图',
link: '/zh/plugins/sitemap/',
Expand Down
21 changes: 21 additions & 0 deletions docs/plugins/seo/README.md
@@ -0,0 +1,21 @@
# seo

<NpmBadge package="@vuepress/plugin-seo" />

## Usage

```bash
npm i -D @vuepress/plugin-seo@next
```

```ts title=".vuepress/config.ts"
import { seoPlugin } from "@vuepress/plugin-seo";

export default {
plugins: [
seoPlugin({
// options
}),
],
}
```
151 changes: 151 additions & 0 deletions docs/plugins/seo/config.md
@@ -0,0 +1,151 @@
# Config

## hostname

- Type: `string`
- Required: Yes
- Details:

Deploy hostname.

## author

- Type: `Author`

```ts
type AuthorName = string;

interface AuthorInfo {
/**
* Author name
*/
name: string;

/**
* Author website
*/
url?: string;

/**
* Author email
*/
email?: string;
}

type Author = AuthorName | AuthorName[] | AuthorInfo | AuthorInfo[];
```

- Required: No

- Details:

Default author.

## autoDescription

- Type: `boolean`
- Default: `true`
- Details:

Whether generate description automatically

## canonical

- Type: `string | ((page: Page) => string | null)`
- Details:

Canonical link

## fallBackImage

- Type: `string`
- Details:

Fallback Image link when no image are found

## restrictions

- Type: `string`
- Details:

The age rating of the content, the format is `[int]+`, such as `"13+"`.

## twitterID

- Type: `string`
- Details:

Fill in your twitter username.

## isArticle

- Type: `(page: Page) => boolean`
- Details:

Use this option to judge whether the page is an article.

## ogp

- Type:

```ts
function ogp(
/** OGP info inferred by plugin */
ogp: SeoContent,
/** Page Object */
page: Page,
/** VuePress App */
app: App,
): SeoContent;
```

- Required: No
- Details:

Custom OPG Generator.

You can use this options to edit OGP tags.

## jsonLd

- Type:

```ts
function jsonLd(
/** JSON-LD Object inferred by plugin */
jsonLD: ArticleSchema | BlogPostingSchema | WebPageSchema,
/** Page Object */
page: Page,
/** VuePress App */
app: App,
): ArticleSchema | BlogPostingSchema | WebPageSchema;
```

- Required: No

- Details:

Custom JSON-LD Generator.

You can use this options to edit JSON-LD properties.

## customHead

- Type:

```ts
function customHead(
/** Head tag config */
head: HeadConfig[],
/** Page Object */
page: Page,
/** VuePress App */
app: App,
): void;
```

- Required: No

- Details:

You can use this options to edit tags injected to `<head>`.

0 comments on commit 8a999c5

Please sign in to comment.