Skip to content
Permalink
Browse files

feat: yuqueLink & yuqueLinkHtml option

  • Loading branch information...
ulivz committed Apr 5, 2019
1 parent c392600 commit b3d7d066a1ad06ad462f74e52c98b7c89caa3ad1
Showing with 22 additions and 2 deletions.
  1. +1 −0 lib/client.js
  2. +11 −2 lib/index.js
  3. +10 −0 lib/style.styl
@@ -0,0 +1 @@
import './style.styl'
@@ -3,7 +3,7 @@
*/

const assert = require('assert')
const { chalk, parseFrontmatter } = require('@vuepress/shared-utils')
const { chalk, parseFrontmatter, path } = require('@vuepress/shared-utils')
const Yuque = require('./yuque')
const { getSidebarByToc } = require('./toc')
const spinner = require('./spinner')
@@ -19,6 +19,10 @@ module.exports = (opts, ctx) => {
return {
name: PACKAGE_NAME,

enhanceAppFiles: [
path.join(__dirname, 'client.js')
],

plugins: [
['@vuepress/medium-zoom', true],
],
@@ -140,11 +144,16 @@ module.exports = (opts, ctx) => {
} = parseFrontmatter(postContent)
const inferredTitle = inferTitle({}, strippedContent)

const content = inferredTitle
let content = inferredTitle
? postContent
: `# ${title} \n\n ${postContent}`

if (opts.yuqueLink) {
content += opts.yuqueLinkHtml || `<br><br><a class="yuque-link" target="_blank" href="${repoUrl}/${slug}"><svg viewBox="64 64 896 896" class="" data-icon="yuque" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M854.6 370.6c-9.9-39.4 9.9-102.2 73.4-124.4l-67.9-3.6s-25.7-90-143.6-98c-117.8-8.1-194.9-3-195-3 .1 0 87.4 55.6 52.4 154.7-25.6 52.5-65.8 95.6-108.8 144.7-1.3 1.3-2.5 2.6-3.5 3.7C319.4 605 96 860 96 860c245.9 64.4 410.7-6.3 508.2-91.1 20.5-.2 35.9-.3 46.3-.3 135.8 0 250.6-117.6 245.9-248.4-3.2-89.9-31.9-110.2-41.8-149.6zm-204.1 334c-10.6 0-26.2.1-46.8.3l-23.6.2-17.8 15.5c-47.1 41-104.4 71.5-171.4 87.6-52.5 12.6-110 16.2-172.7 9.6 18-20.5 36.5-41.6 55.4-63.1 92-104.6 173.8-197.5 236.9-268.5l1.4-1.4 1.3-1.5c4.1-4.6 20.6-23.3 24.7-28.1 9.7-11.1 17.3-19.9 24.5-28.6 30.7-36.7 52.2-67.8 69-102.2l1.6-3.3 1.2-3.4c13.7-38.8 15.4-76.9 6.2-112.8 22.5.7 46.5 1.9 71.7 3.6 33.3 2.3 55.5 12.9 71.1 29.2 5.8 6 10.2 12.5 13.4 18.7 1 2 1.7 3.6 2.3 5l5 17.7c-15.7 34.5-19.9 73.3-11.4 107.2 3 11.8 6.9 22.4 12.3 34.4 2.1 4.7 9.5 20.1 11 23.3 10.3 22.7 15.4 43 16.7 78.7 3.3 94.6-82.7 181.9-182 181.9z"></path></svg> 使用语雀查看</a>`
}

const permalink = `/${slug}.html`

await ctx.addPage({
content,
frontmatter,
@@ -0,0 +1,10 @@
.yuque-link
border: 1px solid #333;
padding: 5px 10px;
color: #333;
border-radius: 3px;
font-weight: 200;
text-decoration none
svg
line-height: 20px;
vertical-align: text-bottom;

0 comments on commit b3d7d06

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