-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Theme index enhancment support #154
Conversation
This works in the same way that .vuepress/enhanceApp.js works but for themes instead allowing theme designers to extend the vue app in more useful ways. This should help with creating custom themes for things like blogging sites like requested in #36
lib/prepare.js
Outdated
? `export { default } from ${JSON.stringify(options.themeApp)}` | ||
: `export default function () {}` | ||
) | ||
|
||
return options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
themeApp
and enhanceApp
are the same except hasEnhancePath
and hasThemeIndexPath
, which can be extracted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly the same, they are two proxy files to two different js files that may or may not exist. They will default to an empty function if they don't exist but are there to load in two different files <theme>/index.js
and .vuepress/enchanceApp.js
respectively into the main vue app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm... you misunderstand my comment, I know WHY and HOW you do that...
I just want you to refactor your code like this:
async function writeEnhanceTemp (destName, srcPath) {
await writeTemp(
destName,
fs.existsSync(srcPath)
? `export { default } from ${JSON.stringify(srcPath)}`
: `export default function () {}`
)
}
// 6. handle enhanceApp.js
const enhanceAppPath = path.resolve(sourceDir, '.vuepress/enhanceApp.js')
await writeEnhanceTemp('enhanceApp.js', enhanceAppPath)
// 7. handle the theme index.js
await writeEnhanceTemp('themeApp.js', options.themeApp)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok, done
Before releasing this we should consider if we want to stick with |
Adds support for loading index.js in themes.
This works in the same way that
.vuepress/enhanceApp.js
works but for themes instead, allowing theme designers to extend the vue app in more useful ways.This should help with creating custom themes for things like blogging sites like requested in #36