Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ This repository:

- holds issues for new and general information for improving existing templates
- downloads each template listed in the [data](./data) folder
- deploys an API to https://api.mystmd.org
- implements a lightweight API that serves an index of template metadata
- deploys that API to https://api.mystmd.org
- automatically updates the organization readme

## Contributing a LaTeX or Typst Template
Expand All @@ -32,7 +33,46 @@ However, data-driven options specified by a `template.yml` are still passed to t

[Fork this repo](https://github.com/myst-templates/templates/fork), make your change and open a PR.

## Development
## Modifying the Template Index

Install the mini CLI tool using `npm install` and `npm run dev` (puts this in watch mode, so you can kill after the output is complete).
Then call `myst-templates-api index data/tex.yml` from the main folder, which will create an index file and update the organization Readme.
To add, remove or update a template in the index, you need to build and run the CLI tool.

1. Install the mini CLI tool using `npm install`
2. Run `npm run build:cli`
3. Run `npm run link`

After you have made your changes to a specific index file(s), call `myst-templates-api index data/tex.yml` from the main folder, which will create an index file and update the organization Readme.

## Source locations

- `./cli`: CLI for generating JSON data files from `data/x.yml` and template clone.
- `./src`: Server for JSON data files.

## Local deployment

To run the API server locally for development and testing:

0. `npm install`

1. `git clone git@github.com:myst-templates/.github.git readme`

The tool wants to populate a README with a list of templates. Provide
it with an example.

2. `npm run build`

- Build CLI into `./dist`.
- Build API server into `./api`.

2. `node dist/myst-templates-api.cjs index data/*.yml`

Combine JSON data files in `data/*.yml` with template information,
obtained from cloned template repos.

3. `npm run copy:data`

Copy JSON data into `src/data`.

4. `node server.js`

Serve data on `https://localhost:10000`.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dev": "npm run link && esbuild cli/index.ts --bundle --outfile=dist/myst-templates-api.cjs --platform=node --watch",
"build:cli": "esbuild cli/index.ts --bundle --outfile=dist/myst-templates-api.cjs --platform=node",
"build:api": "esbuild src/index.ts src/utils.ts --outdir=api --platform=node --format=cjs",
"copy:data": "mkdir api && mkdir api/data && copyfiles -f src/data/*.json api/data",
"copy:data": "mkdir -p api/data && copyfiles -f src/data/*.json api/data",
"build": "npm-run-all -l clean copy:data -p build:cli build:api",
"compile": "tsc --noEmit",
"test": "npm run compile",
Expand Down
4 changes: 4 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const app = require('./api/index.js');

const PORT = process.env.PORT || 10000;
app.listen(PORT, () => console.log(`Listening on ${PORT}`));