choojs / bankai

:station: - friendly web compiler
Apache License 2.0
1.09k stars 102 forks source link

check is turbolinks app #492

Closed ZhouHansen closed 6 years ago

ZhouHansen commented 6 years ago

This is a 🙋 feature.

Check whether is a turbolinks app, then add relative meta tag.

Create a graph-package-json.js to check it, because the document node dependents on it, if this is a turbolinks app, will add <meta name="turbolinks-visit-control" content="reload"> to <head>. May combine it with is-electron-projects.js into one file in the future.

Checklist

Context

No

Semver Changes

minor

goto-bus-stop commented 6 years ago

I like the graph node for package.json! I'm not sure about this feature though … turbolinks doesn't really do anything for choo apps does it? choo handles routing and already only replaces the <body> parts that need to be replaced when you navigate.

ZhouHansen commented 6 years ago

Yeah, I worked on a hybird app which is built by choo and turbolinks. Turbolinks doesn't do anything to choo, it only makes hybird app's page jumping looks more natively, it requires ssr choo and that meta tag.

goto-bus-stop commented 6 years ago

This use case is quite specific, I think it may be better solved with a custom documentify transform, like this:

// package.json
{
  "devDependencies": {
    "hstream": "^1.2.0"
  },
  "documentify": {
    "transform": [
      "./add-turbolinks-meta"
    ]
  }
}
// add-turbolinks-meta.js
var hstream = require('hstream')
module.exports = function () {
  return hstream({
    head: { _appendHtml: '<meta name="turbolinks-visit-control" content="reload">' }
  })
}
ZhouHansen commented 6 years ago

Yeah, maybe it's a better idea.