Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
feat: deprecate modifyBlogPluginOptions (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
billyyyyy3320 authored Jan 22, 2020
1 parent fbe49d4 commit ad5c100
Showing 1 changed file with 34 additions and 42 deletions.
76 changes: 34 additions & 42 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,51 +48,43 @@ module.exports = themeConfig => {
},
}

const { modifyBlogPluginOptions } = themeConfig

let blogPluginOptions

if (typeof modifyBlogPluginOptions === 'function') {
blogPluginOptions = modifyBlogPluginOptions(defaultBlogPluginOptions)
} else {
let resolvedFeedOptions
const isFeedEnabled = themeConfig.feed && themeConfig.feed.canonical_base
if (isFeedEnabled) {
const {
rss = true,
atom = false,
json = false,
...feedOptions
} = themeConfig.feed
resolvedFeedOptions = Object.assign({}, feedOptions, {
feeds: {
rss2: { enable: rss },
atom1: { enable: atom },
json1: { enable: json },
},
})
}

const properties = [
'directories',
'frontmatters',
'globalPagination',
'sitemap',
'comment',
'newsletter',
]
const themeConfigPluginOptions = {
...pick(themeConfig, properties),
feed: resolvedFeedOptions,
}
let resolvedFeedOptions
const isFeedEnabled = themeConfig.feed && themeConfig.feed.canonical_base
if (isFeedEnabled) {
const {
rss = true,
atom = false,
json = false,
...feedOptions
} = themeConfig.feed
resolvedFeedOptions = Object.assign({}, feedOptions, {
feeds: {
rss2: { enable: rss },
atom1: { enable: atom },
json1: { enable: json },
},
})
}

blogPluginOptions = Object.assign(
{},
defaultBlogPluginOptions,
themeConfigPluginOptions
)
const properties = [
'directories',
'frontmatters',
'globalPagination',
'sitemap',
'comment',
'newsletter',
]
const themeConfigPluginOptions = {
...pick(themeConfig, properties),
feed: resolvedFeedOptions,
}

const blogPluginOptions = Object.assign(
{},
defaultBlogPluginOptions,
themeConfigPluginOptions
)

/**
* Integrate plugins
*/
Expand Down

0 comments on commit ad5c100

Please sign in to comment.