Skip to content

Commit

Permalink
chore: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Jan 30, 2024
1 parent 81141a6 commit 90e3327
Show file tree
Hide file tree
Showing 23 changed files with 435 additions and 435 deletions.
4 changes: 2 additions & 2 deletions docs/plugins/feed/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Atom syntax output filename, relative to dest folder.
## atomXslTemplate

- Type: `string`
- Default: Content of `vuepress-plugin-feed2/templates/atom.xsl`
- Default: Content of `@vuepress/plugin-feed/templates/atom.xsl`

Atom xsl template file content.

Expand Down Expand Up @@ -173,7 +173,7 @@ RSS syntax output filename, relative to dest folder.
## rssXslTemplate

- Type: `string`
- Default: Content of `vuepress-plugin-feed2/templates/rss.xsl`
- Default: Content of `@vuepress/plugin-feed/templates/rss.xsl`

RSS xsl template file content.

Expand Down
7 changes: 2 additions & 5 deletions docs/plugins/feed/guide.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
---
title: Guide
icon: lightbulb
---
# Guide

## Usage

The `vuepress-plugin-feed2` plugin can generate feed files in the following three formats for you:
The plugin can generate feed files in the following three formats for you:

- Atom 1.0
- JSON 1.1
Expand Down
4 changes: 2 additions & 2 deletions docs/zh/plugins/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Atom 格式输出路径,相对于输出路径。
## atomXslTemplate

- 类型: `string`
- 默认值: `vuepress-plugin-feed2/templates/atom.xsl` 的内容
- 默认值: `@vuepress/plugin-feed/templates/atom.xsl` 的内容

Atom xsl 模板文件没人陪美国

Expand Down Expand Up @@ -173,7 +173,7 @@ RSS 格式输出路径,相对于输出路径。
## rssXslTemplate

- 类型: `string`
- 默认值: `vuepress-plugin-feed2/templates/rss.xsl` 的内容
- 默认值: `@vuepress/plugin-feed/templates/rss.xsl` 的内容

RSS xsl 模板文件内容。

Expand Down
7 changes: 2 additions & 5 deletions docs/zh/plugins/guide.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
---
title: 指南
icon: lightbulb
---
# 指南

## 使用

`vuepress-plugin-feed2` 插件可为你生成以下三种格式的 feed 文件:
插件可为你生成以下三种格式的 feed 文件:

- Atom 1.0
- JSON 1.1
Expand Down
4 changes: 2 additions & 2 deletions plugins/plugin-feed/src/node/feed/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type { GitData } from '@vuepress/plugin-git'
import type { App, Page } from 'vuepress/core'
import { isString } from 'vuepress/shared'
import type { PageFrontmatter } from 'vuepress/shared'
import type { ResolvedFeedOptions } from '../options.js'
import type {
AuthorInfo,
FeedAuthor,
Expand All @@ -21,7 +20,8 @@ import type {
FeedFrontmatterOption,
FeedGetter,
FeedPluginFrontmatter,
} from '../typings/index.js'
} from '../../typings/index.js'
import type { ResolvedFeedOptions } from '../options.js'
import {
getFeedAuthor,
getFeedCategory,
Expand Down
6 changes: 3 additions & 3 deletions plugins/plugin-feed/src/node/feed/store.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { App } from 'vuepress/core'
import type { FeedLinks, ResolvedFeedOptions } from '../options.js'
import { getFeedChannelOption, getFeedLinks } from '../options.js'
import type {
FeedCategory,
FeedChannelOption,
FeedContributor,
} from '../typings/index.js'
} from '../../typings/index.js'
import type { FeedLinks, ResolvedFeedOptions } from '../options.js'
import { getFeedChannelOption, getFeedLinks } from '../options.js'
import type { FeedItem } from './item.js'

export class FeedStore {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { customizeDevServer } from '@vuepress/helper/node'
import type { PluginFunction, PluginObject } from 'vuepress/core'
import { colors } from 'vuepress/utils'
import type { FeedPluginOptions } from '../typings/index.js'
import { addFeedLinks } from './addFeedLinks.js'
import { getFeedFiles } from './getFeed.js'
import { getAtomTemplates, getRSSTemplates } from './getTemplate.js'
import { checkOutput, ensureHostName, getFeedOptions } from './options.js'
import { writeFiles } from './output.js'
import type { FeedOptions } from './typings/index.js'
import { FEED_GENERATOR, logger } from './utils/index.js'

export const feedPlugin =
(options: FeedOptions): PluginFunction =>
(options: FeedPluginOptions): PluginFunction =>
(app) => {
if (app.env.isDebug) logger.info('Options:', options)

Expand Down
2 changes: 1 addition & 1 deletion plugins/plugin-feed/src/node/generator/atom/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isArray } from '@vuepress/helper/node'
import { js2xml } from 'xml-js'
import type { FeedAuthor, FeedCategory } from '../../../typings/index.js'
import type { FeedStore } from '../../feed/store.js'
import type { FeedAuthor, FeedCategory } from '../../typings/index.js'
import { encodeXML, FEED_GENERATOR } from '../../utils/index.js'
import type {
AtomAuthor,
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugin-feed/src/node/generator/json/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isArray } from '@vuepress/helper/node'
import type { FeedAuthor } from '../../../typings/index.js'
import type { FeedStore } from '../../feed/store.js'
import type { FeedAuthor } from '../../typings/index.js'
import type { JSONAuthor, JSONContent, JSONItem } from './typings.js'

const getJSONAuthor = (author: FeedAuthor): JSONAuthor => ({
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugin-feed/src/node/generator/rss/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { isUrl } from '@vuepress/helper/node'
import { js2xml } from 'xml-js'
import type { FeedCategory, FeedEnclosure } from '../../../typings/index.js'
import type { FeedItem } from '../../feed/item.js'
import type { FeedStore } from '../../feed/store.js'
import type { FeedCategory, FeedEnclosure } from '../../typings/index.js'
import { encodeXML, FEED_GENERATOR } from '../../utils/index.js'
import type {
RSSCategory,
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugin-feed/src/node/getFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { entries, fromEntries } from '@vuepress/helper/node'
import type { GitData } from '@vuepress/plugin-git'
import type { App, Page } from 'vuepress/core'
import { colors } from 'vuepress/utils'
import type { FeedConfig, FeedPluginFrontmatter } from '../typings/index.js'
import { FeedItem } from './feed/item.js'
import { FeedStore } from './feed/store.js'
import { getAtomFeed } from './generator/atom/index.js'
import { getJSONFeed } from './generator/json/index.js'
import { getRssFeed } from './generator/rss/index.js'
import type { ResolvedFeedOptionsMap } from './options.js'
import { getFilename } from './options.js'
import type { FeedConfig, FeedPluginFrontmatter } from './typings/index.js'
import { logger } from './utils/index.js'

export const getFeedFiles = (
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugin-feed/src/node/getTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { entries } from '@vuepress/helper/node'
import { ensureEndingSlash } from 'vuepress/shared'
import { fs, getDirname, path } from 'vuepress/utils'
import type { FeedConfig } from '../typings/index.js'
import type { ResolvedFeedOptionsMap } from './options.js'
import { getFilename } from './options.js'
import type { FeedConfig } from './typings/index.js'

const __dirname = getDirname(import.meta.url)

Expand Down
4 changes: 2 additions & 2 deletions plugins/plugin-feed/src/node/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './plugin.js'
export * from './typings/index.js'
export * from './feedPlugin.js'
export * from '../typings/index.js'
23 changes: 13 additions & 10 deletions plugins/plugin-feed/src/node/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ import {
removeLeadingSlash,
} from 'vuepress/shared'
import type {
BaseFeedOptions,
BaseFeedPluginOptions,
FeedChannelOption,
FeedOptions,
} from './typings/index.js'
FeedPluginOptions,
} from '../typings/index.js'
import { getUrl } from './utils/index.js'

export interface ResolvedFeedOptions
extends Omit<BaseFeedOptions, 'sorter' | 'filter' | 'preservedElements'>,
Required<Pick<BaseFeedOptions, 'sorter' | 'filter'>> {
extends Omit<
BaseFeedPluginOptions,
'sorter' | 'filter' | 'preservedElements'
>,
Required<Pick<BaseFeedPluginOptions, 'sorter' | 'filter'>> {
hostname: string
isPreservedElement: (tagName: string) => boolean
}
Expand All @@ -31,7 +34,7 @@ export type ResolvedFeedOptionsMap = Record<string, ResolvedFeedOptions>

export const ensureHostName = (
app: App,
options: Partial<FeedOptions>,
options: Partial<FeedPluginOptions>,
): boolean => {
const hostname = app.env.isDev
? options.devHostname || `http://localhost:${app.options.port}`
Expand All @@ -49,7 +52,7 @@ export const ensureHostName = (
return false
}

export const checkOutput = (options: Partial<FeedOptions>): boolean =>
export const checkOutput = (options: Partial<FeedPluginOptions>): boolean =>
// some locales request output
(options.locales &&
values(options.locales).some(
Expand All @@ -60,7 +63,7 @@ export const checkOutput = (options: Partial<FeedOptions>): boolean =>

export const getFeedOptions = (
{ siteData }: App,
options: FeedOptions,
options: FeedPluginOptions,
): ResolvedFeedOptionsMap =>
fromEntries(
keys({
Expand Down Expand Up @@ -119,7 +122,7 @@ export const getFeedOptions = (

export const getFeedChannelOption = (
app: App,
options: FeedOptions,
options: FeedPluginOptions,
localePath = '',
): FeedChannelOption => {
const { base } = app.options
Expand Down Expand Up @@ -179,7 +182,7 @@ export const getFilename = (
prefix = '/',
): Required<
Pick<
FeedOptions,
FeedPluginOptions,
| 'atomOutputFilename'
| 'atomXslFilename'
| 'jsonOutputFilename'
Expand Down
Loading

0 comments on commit 90e3327

Please sign in to comment.