saberland/saber

Support rendering the content of a specific page to static HTML string #204

egoist posted onGitHub

<!-- Please don't delete this template or we'll close your issue -->

<!-- Before creating an issue please make sure you are using the latest version of Saber. -->

Feature request

<!-- Please ask questions via following several ways. -->

<!-- https://chat.saber.land/ -->

<!-- https://stackoverflow.com/questions/ask?tags=saberjs -->

What problem does this feature solve?

Currently saber-plugin-feed uses raw content in the generated feed:

https://github.com/saberland/saber/blob/7e32a24e45ea1559f97fee9c53a4ff702af13420/packages/saber-plugin-feed/lib/index.js#L70

This is fine if the page content has absolutely no Vue components, but unfortunately markdown links are compiled to <saber-link>, and we support many other Vue SFC features in pages.

So we should find a way to transform page.content to real/valid HTML.

What does the proposed API look like?

const html = await api.renderer.renderPartial({ url: 'the permalink' })

How should this be implemented in your opinion?

const context = {
  url: '...',
  // ...
  replaceRouteComponentWithThis: {
    return { 
      props: ['page'],
      render() { return h('div', {id:'__saber_content'}, this.$slots.default) }
    }
  }
}

const html = await renderer.renderToString(context)

// then somehow get the html of #__saber_content
// e.g. use posthtml

Are you willing to work on this yourself?


Fund this Issue

$100.00
Rewarded

Rewarded pull request

Recent activities

egoist was rewarded for saberland/saber# 204
almost 6 years ago
egoist submitted an output to  saberland/ saber# 204
almost 6 years ago