-
What would be the easiest way to integrate the observable framework with vite's server side rendering / static site generation based on dynamic routes known at build time? For example, I am using Vike for pre-rendering HTML pages on build for dynamic routes for every public use microdata area in the United States: https://vike.dev/pre-rendering Use case:
Happy to collaborate / chat if others are interested in this, and happy to contribute to the project if this is not supported yet. P.S. Loving the framework development experience so far :) this is like Christmas came early! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
You can reference thousands of files in a project, by listing all of them as static references: ```js
const files = [
FileAttachment("data1.csv"),
FileAttachment("data2.csv"),
// …
FileAttachment("data1000.csv")
];
``` (use a script to build this list); it will build the files into the site. And you can then use (download) those files “dynamically” with FileAttachment (as csv, text, or as a DuckDB source), for example with an input to select the id of the data source: ```js
const FA = FileAttachment;
const id = view(Inputs.range([1, 1000], { step: 1 }));
```
```js
display(FA(`data${id}.csv`));
const data = FA(`data${id}.csv`).csv({ typed: true });
```
```js
display(Inputs.table(data));
```
```js
const db = DuckDBClient.of({ name: FA(`data${id}.csv`).csv({ typed: true }) });
```
```js
display(await db.sql`SELECT * FROM name`);
``` Another way to set a dynamic id it through the page's URL: page?id=12 ```js
const id = +(new URL(document.location).searchParams.get("id") ?? "1"); // 12
``` Note: with the current implementation of FileAttachment, the name of the file is predictable, so you could use HTH. (I'm discovering |
Beta Was this translation helpful? Give feedback.
-
I think I'm hitting a similar issue. I have a list of IDs I need to build a dashboard for. E.g: Wondering if there is a way to (1) skip having to upload and read a 600MB file (only reads 150MB at the end) with each user and (2) also have the Any ideas? |
Beta Was this translation helpful? Give feedback.
-
Framework 1.11.0 adds parameterized routes and page loaders which we recommend for this use case. |
Beta Was this translation helpful? Give feedback.
You can reference thousands of files in a project, by listing all of them as static references:
(use a script to build this list); it will build the files into the site.
And you can then use (download) those files “dynamically” with FileAttachment (as csv, text, or as a DuckDB source), for example with an input to select the id of the data source: