simonw / datasette-leaflet-geojson

Datasette plugin that replaces any GeoJSON column values with a Leaflet map.
20 stars 8 forks source link

Only inject JavaScript on table and query pages #14

Closed simonw closed 4 years ago

simonw commented 4 years ago

The JavaScript should only be injected on pages that are displaying a table. It currently gets injected everywhere including the Datasette instance index.html homepage.

simonw commented 4 years ago

Ideally it would only be injected on pages that have columns containing GeoJSON - but that's not currently possible since the plugin hooks make the names of the columns available as columns but don't let you inspect the individual row data.

The JavaScript could selectively load the Leaflet.js code though.

simonw commented 4 years ago

Easiest solution: see if columns was passed (which means this page will be rendering a table).