Skip to content

v1.1.0

Compare
Choose a tag to compare
@cossssmin cossssmin released this 10 Apr 14:45
· 216 commits to master since this release

This release adds two new options.

plugins

You can now call other plugins that can run before or after the content is fetched:

const posthtml = require('posthtml')
const pf = require('posthtml-fetch')

posthtml()
  .use(pf({
    plugins: {
      after(tree) {
        // Your plugin implementation
      },
      before: [
        tree => {
          // Your plugin implementation
        },
        tree => {
          // Your plugin implementation
        }
      ]
    }
  }))
  .process('<fetch url="https://example.test">{{ response }}</fetch>')
  .then(result => {
    console.log(result.html)
    // => ...interpolated response from https://example.test
  })

preserveTag

Type: boolean
Default: false

You can tell the plugin to preserve the <fetch> tag:

const posthtml = require('posthtml')
const pf = require('posthtml-fetch')

posthtml()
  .use(pf({
    preserveTag: true
  }))
  .process('<fetch url="https://example.test">{{ response }}</fetch>')
  .then(result => {
    console.log(result.html)
    // => <fetch url="https://example.test">...interpolated response from https://example.test</fetch>
  })