update README.md

This commit is contained in:
Quinn Dougherty 2022-08-01 04:03:01 -04:00
parent e1cb86c11d
commit 46dec0ea85
3 changed files with 38 additions and 22 deletions

View File

@ -1,22 +1,53 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
This is a `create-next-app` template for presenting a collection of estimates in [squiggle](https://squiggle-language.com)
```bash
yarn create next-app our-estimates --example https://github.com/quantified-uncertainty/next-app-with-squiggle
```
## Getting Started
First, run the development server:
```bash
npm run dev
# or
yarn dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
Edit the `.mdx` files in `pages` with your estimates
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
```bash
pages
├── _app.tsx
├── index.tsx
├── intro.md
├── latex-demo.md
├── squiggle-demo.mdx
├── team.md
└── worldview
├── ai.mdx
├── bio.mdx
└── index.md
```
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
After copying your `.squiggle` files into `public/estimates`
``` bash
public/
├── estimates
│   └── baz.squiggle
├── favicon.ico
├── quri-logo.png
└── quri-logo-with-QURI-written-underneath.png
```
A typical invocation of squiggle in a `.mdx` file is as follows
``` jsx
import { DynamicSquiggleEditorWithImportedBindings as SquiggleEditor } from "../components/DynamicSquiggleEditorWithImportedBindings"
<SquiggleEditor defaultCode="xrisk.bioRiskAtYearAfter2022(4)" bindingsImportUrl="/estimates/xrisk.squiggle" />
```
## Learn More
@ -31,4 +62,4 @@ You can check out [the Next.js GitHub repository](https://github.com/vercel/next
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Check out the [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

View File

@ -1,6 +1,4 @@
{
"name": "next-app-with-squiggle",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",

View File

@ -1,13 +0,0 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from 'next'
type Data = {
name: string
}
export default function handler(
req: NextApiRequest,
res: NextApiResponse<Data>
) {
res.status(200).json({ name: 'John Doe' })
}