Skip to content
Permalink
Browse files

feat: "home" option and default title and description

  • Loading branch information...
ulivz committed Feb 4, 2019
1 parent 9b6c95a commit 7b2505dfc3f95498eaeff3e6353d08bcc01aa11e
Showing with 41 additions and 9 deletions.
  1. +7 −3 example/.vuepress/config.js
  2. +0 −3 example/README.md
  3. +34 −3 lib/index.js
@@ -1,11 +1,15 @@
module.exports = {
title: 'Ant Design 实战教程',
description: 'build your yuque\'s docs via vuepress',
plugins: [
[
require('../../lib/index.js'),
{
repoId: '146550'
repoId: '146550',
home: {
// actionText: 'Getting Started →',
// actionLink: '/intro/',
// heroImage: 'https://cdn.nlark.com/yuque/0/2018/png/84868/1535520500482-avatar/20c595c5-ab31-4543-9142-f36cc87c8868.png?x-oss-process=image/resize,m_fill,w_320,h_320',
// footer: `Copyright © 蚂蚁金服体验技术部`
}
}
]
]

This file was deleted.

Oops, something went wrong.
@@ -51,7 +51,7 @@ module.exports = (opts, ctx) => {
}
spinner.succeed(`Retrieved repo detail`)

const { name, description } = repoDetail.data
const { name, description, user } = repoDetail.data
spinner.succeed(
`Your Yuque website: ${chalk.green(name)} ` +
`${chalk.gray(description)} ...`
@@ -72,6 +72,14 @@ module.exports = (opts, ctx) => {
const sidebar = getSidebarByToc(toc.data)
ctx.siteConfig.themeConfig = ctx.siteConfig.themeConfig || {}
ctx.siteConfig.themeConfig.sidebar = sidebar
if (!ctx.siteConfig.title) {
ctx.siteConfig.title = name
}
if (!ctx.siteConfig.description) {
ctx.siteConfig.description = description
}

let defaultActionLink

// Apply pages
for (const page of toc.data) {
@@ -96,15 +104,38 @@ module.exports = (opts, ctx) => {
? postContent
: `# ${title} \n ${postContent}`

const permalink = `/${slug}/`
await ctx.addPage({
content,
frontmatter,
permalink: `/${slug}/`
permalink
})

if (!defaultActionLink) {
defaultActionLink = permalink
}

spinner.succeed(`Retrieved ${chalk.cyan(title)} ... `)
}

if (ctx.pages.every(page => page.path !== '/')) {
const { home = {} } = opts
const { actionText, actionLink, heroImage, features, footer } = home

spinner.info(`Apply default homepage`)
await ctx.addPage({
content: '',
permalink: '/',
frontmatter: {
home: true,
heroImage: heroImage || user.large_avatar_url,
actionText: actionText || 'Getting Started →',
actionLink: actionLink || defaultActionLink,
features: features || undefined,
footer: footer || `Copyright © ${user.name}`,
}
})
}
}
}
}

0 comments on commit 7b2505d

Please sign in to comment.
You can’t perform that action at this time.