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

Invoke a hook before/after generating a page #89

Closed
egoist opened this issue May 1, 2019 · 10 comments
Closed

Invoke a hook before/after generating a page #89

egoist opened this issue May 1, 2019 · 10 comments
Labels
Projects

Comments

@egoist
Copy link
Collaborator

egoist commented May 1, 2019

Issuehunt badges

Feature request

What problem does this feature solve?

Would be useful for https://github.com/egoist/saber/issues/71

What does the proposed API look like?

api.hooks.afterGeneratePage.tapPromise(ID, context => {
  const amp = shouldGenerateAMPPage(context)
  if (amp) {
    //...
  }
})

How should this be implemented in your opinion?

N/A

Are you willing to work on this yourself?

PR welcome.

marchworks earned $20.00 by resolving this issue!

@issuehunt-oss issuehunt-oss bot added the 💵 Funded on Issuehunt This issue has been funded on Issuehunt label May 1, 2019
@IssueHuntBot
Copy link

@IssueHunt has funded $20.00 to this issue.


@nblthree
Copy link
Member

nblthree commented May 1, 2019

@egoist
Copy link
Collaborator Author

egoist commented May 1, 2019

@nblthree
Copy link
Member

nblthree commented May 2, 2019

I added a console.log there but it doesn't get executed in dev mode

@egoist
Copy link
Collaborator Author

egoist commented May 2, 2019

yes, ssr is for production only, in dev it runs as a spa

@nblthree
Copy link
Member

nblthree commented May 2, 2019

https://github.com/egoist/saber/issues/107#issuecomment-488584989

btw probably we should allow to run app in SSR in dev mode, useful for debugging.

should I await this or what?

@egoist
Copy link
Collaborator Author

egoist commented May 2, 2019

nope, that's not our top priority, and it will be an optional feature.

@nblthree
Copy link
Member

nblthree commented May 2, 2019

so I have done

await this.api.hooks.beforeGeneratePage.promise(context)
await fs.outputFile(route.outputFilePath, html, 'utf8')
await this.api.hooks.afterGeneratePage.promise(context)

here https://github.com/egoist/saber/blob/38fe0a48b382854456a4b58c4dd253229bb17885/packages/saber/vue-renderer/lib/index.js#L279 which work fine in the build process for the dev mode I am not sure if this is the right place https://github.com/egoist/saber/blob/38fe0a48b382854456a4b58c4dd253229bb17885/packages/saber/vue-renderer/lib/index.js#L411

@egoist
Copy link
Collaborator Author

egoist commented May 2, 2019

we don't need this hook in dev mode

@egoist egoist added this to To do (0.5) in Roadmap May 2, 2019
@egoist egoist closed this as completed in 7002f6e May 2, 2019
Roadmap automation moved this from To do (0.5) to Done May 2, 2019
@issuehunt-oss issuehunt-oss bot added 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt and removed 💵 Funded on Issuehunt This issue has been funded on Issuehunt labels May 2, 2019
@IssueHuntBot
Copy link

@egoist has rewarded $14.00 to @marchworks. See it on IssueHunt

  • 💰 Total deposit: $20.00
  • 🎉 Repository reward(20%): $4.00
  • 🔧 Service fee(10%): $2.00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Roadmap
  
Done
Development

No branches or pull requests

3 participants