Skip to content
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

Merged
merged 6 commits into from
Apr 23, 2018
Merged

Theme index enhancment support #154

merged 6 commits into from
Apr 23, 2018

Conversation

mdaffin
Copy link
Contributor

@mdaffin mdaffin commented Apr 19, 2018

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

Michael Daffin added 2 commits April 19, 2018 13:48
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
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@ulivz ulivz Apr 19, 2018

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok, done

@yyx990803 yyx990803 merged commit d026801 into vuejs:master Apr 23, 2018
@mdaffin
Copy link
Contributor Author

mdaffin commented Apr 23, 2018

Before releasing this we should consider if we want to stick with index.js or use something else as we might want to use index.js for theme plugins as in #196

@mdaffin mdaffin deleted the theme-index branch April 25, 2018 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants