Skip to content

Allow injecting Vue #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ footer: MIT Licensed | Copyright © 2018-present Evan You
npm install -g vuepress

# create a markdown file
echo # Hello VuePress > README.md
echo '# Hello VuePress' > README.md

# start writing
vuepress dev
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ If you just want to play around with VuePress, you can install it globally:
npm install -g vuepress

# create a markdown file
echo # Hello VuePress > README.md
echo '# Hello VuePress' > README.md

# start writing
vuepress dev
Expand All @@ -29,7 +29,7 @@ npm install -D vuepress
# create a docs directory
mkdir docs
# create a markdown file
echo # Hello VuePress > docs/README.md
echo '# Hello VuePress' > docs/README.md

# start writing
npx vuepress dev docs
Expand Down
4 changes: 4 additions & 0 deletions lib/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import dataMixin from './dataMixin'
import NotFound from '@notFound'
import { routes } from '@temp/routes'
import { siteData } from '@temp/siteData'
import inject from '@temp/inject'

// suggest dev server restart on base change
if (module.hot) {
Expand Down Expand Up @@ -73,5 +74,8 @@ export function createApp () {
}
})

// user inject
inject({ Vue, app, router })

return { ...{ app, router }}
}
9 changes: 8 additions & 1 deletion lib/default-theme/styles/theme.styl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ p a code
font-weight 400
color $accentColor

kbd
background #eee
border solid 0.15rem #ddd
border-bottom solid 0.25rem #ddd
border-radius 0.15rem
padding 0 0.15em

blockquote
font-size 1.2rem
color #999
Expand Down Expand Up @@ -120,7 +127,7 @@ a.header-anchor
&:hover
text-decoration none

code
code, kbd
font-family source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace

p, ul, ol
Expand Down
10 changes: 10 additions & 0 deletions lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ if (!Object.assign) Object.assign = require('object-assign')`
await writeTemp(`override.styl`, hasUserOverride ? `@import(${JSON.stringify(overridePath)})` : ``)
}

// 6. handle user inject
const injectPath = path.resolve(sourceDir, '.vuepress/inject.js')
const hasUserInject = fs.existsSync(injectPath)
await writeTemp(
'inject.js',
hasUserInject
? `export { default } from ${JSON.stringify(injectPath)}`
: `export default function () {}`
)

return options
}

Expand Down