|
2 | 2 | keywords: embedded analytics, embeds, iframe, exporting, exports
|
3 | 3 | ---
|
4 | 4 |
|
5 |
| -# Embedding <a href="https://github.com/observablehq/framework/pull/1637" class="observablehq-version-badge" data-version="prerelease" title="Added in #1637"></a> |
| 5 | +# Embedding <a href="https://github.com/observablehq/framework/releases/tag/v1.12.0" class="observablehq-version-badge" data-version="^1.12.0" title="Added in 1.12.0"></a> |
6 | 6 |
|
7 | 7 | In addition to standalone apps, you can use Framework to embed interactive views within other applications. Framework supports multiple approaches to embedding:
|
8 | 8 |
|
@@ -109,16 +109,37 @@ Some web tooling such as Vite and Webpack erroneously rewrite external dynamic i
|
109 | 109 |
|
110 | 110 | ## Exported files
|
111 | 111 |
|
112 |
| -In addition to modules, you can declare specific files to export using the [**dynamicPaths** config option](./config#dynamic-paths). Exported files are published under a stable URL that can be linked to and loaded from an external application. Exported files can be either [static files](./files) or generated dynamically by [data loaders](./data-loaders), and can use [parameterized routes](./params). For example, to export the file `/robots.txt`: |
| 112 | +You can declare specific files to export using the [**dynamicPaths** config option](./config#dynamic-paths). Exported files are published under a stable URL that can be linked to and loaded from an external application. Exported files can be either [static](./files) or generated dynamically by [data loaders](./data-loaders). And you can use [parameterized routes](./params). |
| 113 | +
|
| 114 | +For example, say you want to chart downloads of open-source libraries you maintain. You could use a data loader to server-side render SVG with Observable Plot. (See Plot’s [Getting Started](https://observablehq.com/plot/getting-started#plot-in-node-js) guide.) In your config file, list the charts you want to build: |
113 | 115 |
|
114 | 116 | ```js run=false
|
115 | 117 | export default {
|
116 | 118 | dynamicPaths: [
|
117 |
| - "/robots.txt" |
| 119 | + "/@observablehq/framework/downloads-dark.svg", |
| 120 | + "/@observablehq/framework/downloads.svg", |
| 121 | + "/@observablehq/plot/downloads-dark.svg", |
| 122 | + "/@observablehq/plot/downloads.svg", |
| 123 | + "/@observablehq/runtime/downloads-dark.svg", |
| 124 | + "/@observablehq/runtime/downloads.svg" |
118 | 125 | ]
|
119 | 126 | };
|
120 | 127 | ```
|
121 | 128 |
|
| 129 | +Once your app is deployed, you can then load the generated SVG into another app — or READMEs on GitHub — using the `img` tag. For example, below is a chart of daily downloads of Observable Framework powered by our [open-source analytics](https://github.com/observablehq/oss-analytics/). |
| 130 | +
|
| 131 | +<picture> |
| 132 | + <source media="(prefers-color-scheme: dark)" srcset="https://observablehq.observablehq.cloud/oss-analytics/@observablehq/framework/downloads-dark.svg"> |
| 133 | + <img style="margin-top: 1rem;" alt="Daily downloads of Observable Framework" src="https://observablehq.observablehq.cloud/oss-analytics/@observablehq/framework/downloads.svg"> |
| 134 | +</picture> |
| 135 | +
|
| 136 | +```html run=false |
| 137 | +<picture> |
| 138 | + <source media="(prefers-color-scheme: dark)" srcset="https://observablehq.observablehq.cloud/oss-analytics/@observablehq/framework/downloads-dark.svg"> |
| 139 | + <img alt="Daily downloads of Observable Framework" src="https://observablehq.observablehq.cloud/oss-analytics/@observablehq/framework/downloads.svg"> |
| 140 | +</picture> |
| 141 | +``` |
| 142 | +
|
122 | 143 | ## Iframe embeds
|
123 | 144 |
|
124 | 145 | You can alternatively embed Framework pages using iframes. Pages that are intended to be embedded via iframe typically disable Framework’s built-in user interface using [Markdown front matter](./markdown#front-matter):
|
|
0 commit comments