An open API service indexing awesome lists of open source software.

https://github.com/open-innovations/yff-data

Source of the Youth Futures Foundation data dashboard
https://github.com/open-innovations/yff-data

deno lume

Last synced: 5 months ago
JSON representation

Source of the Youth Futures Foundation data dashboard

Awesome Lists containing this project

README

          

# yff-data

> Source of the Youth Futures Foundation data portal

To run the latest version of the code, set the VERSION environmment variable. On a macos / Linux platform this can be done as follows:

```sh
VERSION=v2 deno task serve
```

## Data

Data to drive visualisations is managed in the `_data/sources` directory.
This allows it to be loaded as [Lume shared data](https://lume.land/docs/creating-pages/shared-data/).
During the build process, this directory is first copied to the `src/data` directory, and from there
to the `/data` path in the built site. This provides the exact data used as a static asset.

In visualisations, the path to data files is provided in the format `/data/path/to/data.csv`.
This is converted to the loaded data path (e.g. `sources.path.to.data`) by the visualisation components.
Please note, that the extension is ignored. Note that data files with the same name but a different
extension will be merged at the object level. Any keys will be taken from the last loaded value, which is
potentially indeterminate! The safest thing is to ensure no potential clashes.

### Importing external data

Remote data is imported using the `dvc import-url` command.

```sh
dvc import-url ()
```

This creates a `.dvc` which tracks the remote file. It can be refreshed using the command `dvc update .dvc`. To refresh a whole directory, run

```sh
dvc update -R working
```

If the entry `frozen: true` is removed from the `.dvc` file, the `repro` subcommand can also be used. To run all the pipelines, including pulling data updates, this should suffice.

```sh
dvc repro -R scripts
```

## Pre-requisites

You will need to have [`deno` installed](https://deno.land/#installation) and in your path.

## Building / Serving

The `deno.json` file includes useful tasks:

`deno task serve` - serves the site at https://localhost:3000/.

`deno task build` - builds the site into `_site`

## Versioned content

Navigation order and inclusion is set on a per-page basis by including the nav_order data in the front-matter for a page. It takes the following format:

```
nav_order:
:
```

in `_config.ts`, the `version` global data is set. By convention this is set to `v1`, `v2`, etc - but could be anything.

The `nav` component interprets this and selects the pages to include based on the presence of the relevant key.

Similarly, the homepage versions (`/home/v1.njk`, `/home/v2.njk`) are set to be the site homepage by comparison between their slug (`v1`, `v2`) and the global data version. If the slug matches the version, the url for the page is set to `/`, otherwise it defaults to `/home/v/`. This is done in the `/home/_data.ts` file.

## Troubleshooting

If the site fails to build based on memory errors, you can try adding the following to the invocation of `deno` in the `deno.json` file.

```
deno run --v8-flags=--max-old-space-size=2048...
```

## License

The code to build this portal is [licensed under the terms of an MIT License](./LICENSE) by [Open Innovations](https://open-innovations.org).