Add initial alpha prototype version
diff --git a/docs/.gitignore b/docs/.gitignore
index b2d6de3..72027a2 100644
--- a/docs/.gitignore
+++ b/docs/.gitignore
@@ -3,6 +3,7 @@
# Production
/build
+/dist
# Generated files
.docusaurus
diff --git a/docs/docs/features/ConduitSubrequests.png b/docs/docs/features/ConduitSubrequests.png
new file mode 100644
index 0000000..a9149d0
--- /dev/null
+++ b/docs/docs/features/ConduitSubrequests.png
Binary files differ
diff --git a/docs/docs/features/_category_.json b/docs/docs/features/_category_.json
new file mode 100644
index 0000000..45de7f0
--- /dev/null
+++ b/docs/docs/features/_category_.json
@@ -0,0 +1,6 @@
+{
+ "position": 2,
+ "label": "Features",
+ "collapsible": true,
+ "collapsed": false
+}
\ No newline at end of file
diff --git a/docs/docs/features/conduit.md b/docs/docs/features/conduit.md
new file mode 100644
index 0000000..b8dc52c
--- /dev/null
+++ b/docs/docs/features/conduit.md
@@ -0,0 +1,205 @@
+---
+sidebar_position: 4
+---
+
+# Conduit
+
+Whenever you setup an API sever, you also need to setup a client
+to consume the interfaces you expose. Yggdrasil Server Conduit allows
+you to simply define functions that take and return JSON-serializable
+data, then it handles the transit for you. Conduit provides options for
+constructing a type-safe TypeScript client, providing your own fetcher, and more.
+
+## Requests and subrequests
+
+Conduit supports both client-to-server requests and server-to-server requests.
+The latter case is useful particularly for modern server architectures that may
+need to make many subrequests to different internal services in order
+to respond to a single external request. Consider the following example:
+
+
+
+The above example illustrates how a To-Do application might be setup to
+respond to requests. When the user loads the To-Do application
+(the "Initial Request" in the diagram), the application needs to get the
+user's tasks in order to render a webpage with their data. To get the user's
+tasks, the frontend server makes a Conduit request to an internal API
+called `getMyTasks()`. The `getMyTasks()` API needs to authenticate the user
+in order to load their data, so it makes a Conduit request to an internal
+API called `authConsumer()`. Thus, the single request to the frontend
+server triggers multiple subrequests internally.
+
+Conduit makes these types of configurations easy by providing the following
+server-to-server features:
+
+- When an uncaught `YggdrasilStatus` error is thrown from a Conduit request, it will be passed up and thrown in the client as well, allowing deeply nested errors to automatically "bubble up" to the end user.
+ - In the example above, this means that if `authConsumer()` throws a `YggdrasilStatus`, it will be thrown all the way up to the frontend server's Conduit client.
+- Conduit APIs are able to add headers to the final response. This is implemented by passing the headers up through Conduit response data. When a non-Conduit request is found, the headers are added to the actual response.
+ - In the example above, this allows `authConsumer()` to append a `Set-Cookie` header to the frontend's response rotate the user's tokens.
+- Conduit APIs can define a set of context parameters common to all APIs. The required context is provided by the client when constructing the Conduit client and will be passed to all APIs called without the need to explicitly include them in each function call.
+ - In the example above, this allows the authentication server to expect context parameters such as `cookie`, `user_agent`, and `ip_address`. This allows the authentication server to read session cookies and perform audit logging.
+
+## Assumptions and limitations
+
+- Your API must be defined as an object, optionally including nested objects, that can only include valid API functions.
+- Each argument in your API's functions must be JSON-serializable.
+- Your API's functions must be asynchronous (return a Promise).
+- Your API function and nested object names must be safe to include in URL paths.
+- Conduit type safety only occurs at compile time through TypeScript.
+ At runtime, the client constructs functions dynamically, so nothing stops it from making invalid requests.
+ For example, TypeScript would stop you from calling `client.this.path.does.not.exist()`,
+ but this would work at runtime for any arbitrary path (this example makes a request to `/this/path/does/not/exist`).
+- The Conduit server client must be called from a Yggdrasil context. This means that you must include it as
+ a top-level function in your ctx, and call it via ygg.ctx().\<the name of your conduit client\>().
+ Please refer to the "Context" documentation for more information.
+
+## Implementation
+
+### Define your API
+
+To use Conduit's type safety features, you'll need to define your
+API's types in a file that can be imported from the client. This may
+involve putting it in an NPM package, git submodule, etc.
+
+```ts title="my-shared-library/conduit.ts"
+import { YggdrasilConduitAPI } from "@jottocraft/yggdrasil";
+
+// This defines the type of your Conduit API.
+export type MyAPI = YggdrasilConduitAPI<{
+ /** The first argument to YggdrasilConduitAPI defines your API functions available to the client. */
+ hello: (time: "morning" | "evening" | "afternoon" | "night") => Promise<string>;
+ goodbye: () => Promise<string>;
+}, {
+ /** The second argument defines common context parameters passed to all Conduit API calls. */
+ name: string;
+}>;
+
+// It's recommended to define the client options here to ensure consistency.
+// They can always be overridden if needed.
+export const myConduitClientOptions: YggdrasilConduitClientOptions = {
+ baseURL: "https://yggdrasil.ns.jottocraft.com/my-api/conduit/"
+};
+```
+
+### Add your API type to YggdrasilServer
+
+```ts title="src/server.ts"
+// Adding MyAPI here lets YggdrasilServer know what to expect so it
+// can throw an error if you forget to implement a function.
+export const DemoServer = new YggdrasilServer<AppCtx, MyAPI>();
+```
+
+### Implement your API
+
+Now, simply write functions that implement your API! Note that
+in your server-side implementation, a `YggdrasilConduitContext` object
+is added before your own arguments so you can utilize Yggdrasil
+Server features in your handlers. `YggdrasilConduitContext` extends
+`YggdrasilContext` with additional Conduit-specific features, such as
+the ability to add headers to the upstream request.
+
+```ts title="src/api/hello.ts"
+import { DemoServer } from "../server";
+
+export const hello = DemoServer.defineAPI().hello(async (ygg, time) => {
+ // Adds a sample header to the upstream request. If a web server is calling
+ // this API, this header will be sent not on the API response, but on the final
+ // web server's response given to the user.
+ ygg.upstreamHeaders.set["X-My-Header"] = "My-Value";
+
+ // Notice how `time` is a parameter, while `name` comes from the common Conduit API context.
+ return "Good " + time + " " + ygg.apiCtx.name + "!";
+});
+```
+
+### Re-export all the routes from a single file
+
+```ts title="src/api/index.ts"
+export * from "./hello";
+// repeat the above for each route file in your project
+```
+
+### Handle requests
+
+Once you have your API handlers defined, simply call YggdrasilConduitServer.handleRequest
+to serve your API:
+
+```ts title="src/index.ts"
+import * as api from "./api";
+
+// This should ideally be defined outside your request handler
+const DemoConduitServer = new YggdrasilConduitServer(DemoServer, api);
+
+// Additional required setup omitted for brevity
+
+// Inside DemoServer.handleRequest:
+return DemoConduitServer.handleRequest(ygg);
+```
+
+## Call your API from a client
+
+### From another Yggdrasil Server instance
+
+To call a Conduit API from another Yggdrasil Server instance,
+call `createConduitClientSideClient()` to create a client.
+
+The client **must** be stored and called as a top-level method in
+your app's context so that the request's context can be bound to it.
+See the "Context" documentation for more details.
+
+```ts title="src/index.ts"
+import { MyAPI } from "my-shared-library/conduit.ts";
+import { createConduitServerSideClient } from "@jottocraft/yggdrasil";
+
+AnotherDemoServer.handleRequest(request, async (ygg) => {
+ // Call the Conduit API
+ const greeting = await ygg.ctx().conduit().hello("morning");
+
+ // Do whatever you want based on the outcome
+}, {
+ // All Conduit clients MUST be defined here (as top-level methods).
+ // They can be named whatever you want.
+ conduit: createConduitServerSideClient<MyAPI>({
+ // Common context about this request to send to MyAPI
+ name: "jottocraft"
+ }, {
+ // Options (baseURL is required)
+ baseURL: "https://yggdrasil.ns.jottocraft.com/demo/conduit/"
+ })
+
+ // The rest of your app's context
+}, {
+ // YggdrasilServer options
+});
+```
+
+### From an external source
+
+Call `createConduitClientSideClient()` to create a client
+for use outside a Yggdrasil Server context. When you call a
+Conduit API from this client, `upstreamHeaders` from the API will
+be discarded, and you'll need to handle errors yourself.
+
+When an error occurs, a `YggdrasilClientStatus` object will
+be thrown. `YggdrasilClientStatus` is nearly identical to
+its server counterpart (`YggdrasilStatus`), but without an
+associated server context.
+
+```ts title="src/index.ts"
+import { MyAPI } from "my-shared-library/conduit.ts";
+import { createConduitClientSideClient } from "@jottocraft/yggdrasil";
+
+async function fetchConduitData() {
+ const conduit = createConduitClientSideClient<MyAPI>({
+ // Common context about this request to send to MyAPI
+ name: "jottocraft"
+ }, {
+ // Options (baseURL is required)
+ baseURL: "https://yggdrasil.ns.jottocraft.com/demo/conduit/"
+ });
+
+ const greeting = await conduit.hello("morning");
+
+ // Do whatever you want based on the outcome
+}
+```
\ No newline at end of file
diff --git a/docs/docs/features/context.md b/docs/docs/features/context.md
new file mode 100644
index 0000000..dded0e8
--- /dev/null
+++ b/docs/docs/features/context.md
@@ -0,0 +1,50 @@
+---
+sidebar_position: 1
+---
+
+# Context
+
+To make it easy to pass state between functions responding to a request,
+Yggdrasil Server packages the original request, normalized parameters, options,
+your app's context, utilities, and more in a single, shared `YggdrasilServerContext` object
+(commonly named `ygg`).
+
+Some Yggdrasil Server features (Yggdrasil Server Router and Conduit) have their own
+state that they provide to you via an extended version of the `YggdrasilServerContext`.
+This extended version uses prototype-based inheritance so that methods implemented in
+the original object continue to run there.
+
+To make it so that you don't have to pass `ygg` into every function you call, and to
+ensure the correct context (base/extended) is being referenced, built-in functions
+that live in the `ygg` context object uses the `this` keyword to access the context.
+Additionally, functions that you add as top-level members to your app's context object
+will be appropriately bound so that they can access the context through `this` (the
+Conduit server client requires this).
+
+Please observe the following practices to avoid inadvertently breaking Yggdrasil Server's context:
+
+## Accessing context
+
+Always use the `ygg` variable passed to you, if provided to you by Yggdrasil Server.
+While you can and should pass the `ygg` variable to your own helper functions, you
+should not use the base context object from a Conduit handler, for example (the Conduit
+context provided by Yggdrasil Server should be used instead). Additionally, do not
+store the `ygg` variable outside or beyond the scope of a request.
+
+## Calling context-based functions
+
+Always access context functions and members directly through the context object.
+Do not store them in another variable, or the `this` context will be broken.
+For example, do `throw ygg.status(400, "NOT_FOUND")` instead of
+`const status = ygg.status; throw status(400, "NOT_FOUND");`. Furthermore,
+do not use `.bind`, `.apply`, or anything else that changes the `this` context.
+
+## Using your own context-based functions
+
+Any top-level member functions present in your app context will be automatically
+bound to the appropriate context, so you can use `this` inside them to access
+the context without requiring a separate `ygg` parameter (this is why `ygg.ctx` is
+a function instead of an object). Please note that this strategy is intended only
+for accessing whatever context is available. If you specifically need a Conduit
+context, for example, it is recommended to use an explicit `ygg` parameter to
+enforce that.
\ No newline at end of file
diff --git a/docs/docs/features/errors.md b/docs/docs/features/errors.md
new file mode 100644
index 0000000..cc0a519
--- /dev/null
+++ b/docs/docs/features/errors.md
@@ -0,0 +1,75 @@
+---
+sidebar_position: 2
+---
+
+# Error handling
+
+Yggdrasil Server has a built-in error handling mechanism. To use it, simply throw
+a `YggdrasilStatus` object from inside a request handler:
+
+```ts
+throw new YggdrasilStatus(404, "INVALID_ROUTE", "The page you're trying to load doesn't exist.");
+```
+
+For your convenience, Yggdrasil Server also provides an assert function that throws
+a `YggdrasilStatus` for you upon failure:
+
+```ts
+ygg.assert(user.isAuthenticated, 401, "AUTH_REQUIRED", "You need to be signed in to load this page.");
+```
+
+## YggdrasilStatus parameters
+
+The `YggdrasilStatus` constructor and `ygg.assert` function share a common set of parameters.
+Those parameters are:
+
+1. [The HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) to return.
+ The name of the status code should match the nature of the error.
+2. A custom status code (something like "AUTH_REQUIRED"). This should be a brief error ID
+ that should allow you to identify where the error was thrown from in your code, and also
+ allow users to identify the error through bug reports, web searches, etc.
+3. (optional) A custom status message to show to the user to help them understand the nature
+ of the error, how they might resolve it, additional details, etc.
+
+## Built-in errors
+
+Yggdrasil Server itself may throw a `YggdrasilStatus` if your configuration causes an
+unworkable state. When Yggdrasil Server itself throws an error, it will use an status
+code prefixed with `YGG_`. Please don't prefix any of your own status codes with `YGG_`.
+
+Just because one of these errors is thrown doesn't mean your app is badly configured, however.
+For example, if your server's base URL is in a subdirectory, and it's deployed behind a
+reverse proxy that routes other directories elsewhere, you may receive a
+`YGG_BASE_URL_MISMATCH` when you try to load the root path directly (without going through
+the proxy), but this would be expected since your reverse proxy would otherwise
+route that path somewhere else on the user-facing URL.
+
+### List of built-in errors
+
+| HTTP status code | Yggdrasil status code | Description |
+| - | - | - |
+| 404 | `YGG_BASE_URL_MISMATCH` | Thrown when your base URL indicates that your server is deployed in a sub-directory (e.g. `/app`), but the requested URL does not use that prefix. |
+| 404 | `YGG_ROUTE_NOT_FOUND` | Thrown when YggdrasilRouter can't find a route that matches the request's path. |
+| 405 | `YGG_ROUTE_METHOD_MISMATCH` | Thrown when YggdrasilRouter finds route(s) that matches the request's path, but none of them match the request's method. |
+| 404 | `YGG_API_NOT_FOUND` | Thrown when YggdrasilConduitServer can't find a Conduit API implementation that matches the request. |
+| 400 | `YGG_BAD_API_REQUEST` | Thrown when YggdrasilConduitServer detects an invalid Conduit API request. |
+| 500 | `YGG_BADLY_CONFIGURED` | Thrown when Yggdrasil Server is unable to proceed due to a misconfiguration, such as missing a required option, contradictory settings, etc. The error message describes the nature of the misconfiguration. |
+
+## Status pages
+
+When a `YggdrasilStatus` object is thrown and uncaught by your handler, Yggdrasil Server will
+return a Response with the corresponding HTTP status code and a generated status page:
+
+| Request Accept | Response type | Description |
+| - | - | - |
+| `application/json+jottocraft-ygg-res` | `application/json+jottocraft-ygg-res` | Returns all the information necessary to pass along the status to the callee's instance of Yggdrasil Server. Please see the Conduit feature documentation for more information. |
+| `application/json` | `application/json` | This currently does the same thing as requests accepting `application/json+jottocraft-ygg-res`. |
+| `text/html` | `text/html` | Calls `ygg.options.generateHtmlStatusPage()` if this is something you've implemented. |
+| Anything else | `text/plain` | Returns a presentable plaintext status page detailing the error. |
+
+## Uncaught errors
+
+The bulk of this document details how Yggdrasil Server handles uncaught `YggdrasilStatus`
+objects to generate a status page. Please keep in mind that this behavior **only applies
+to `YggdrasilStatus` objects**. Any other errors that happen in your code will remain
+uncaught, and it's up to you to determine how those should be handled.
\ No newline at end of file
diff --git a/docs/docs/features/router.md b/docs/docs/features/router.md
new file mode 100644
index 0000000..653def8
--- /dev/null
+++ b/docs/docs/features/router.md
@@ -0,0 +1,147 @@
+---
+sidebar_position: 3
+---
+
+# Router
+
+Yggdrasil Server includes a simple router. With the router, you can
+register different handlers for each URL path and method combination
+you support. Then, Yggdrasil Server will call the appropriate handler
+when requests come in.
+
+## Implementation
+
+### Setup routes
+
+To define routes, simply use YggdrasilServer.defineRoute to create a
+route object. Then, pass all of your route objects into YggdrasilRouter's
+constructor to register them.
+
+Please note that route handlers are passed a YggdrasilRouterContext,
+which extends YggdrasilContext with additional context about your routing.
+
+The following sample shows how to define and register routes using
+the recommended convention that keeps each route defined in its own file:
+
+```ts title="src/routes/hello.ts"
+import { DemoServer } from "../server";
+
+// The first parameter is the HTTP method, or * to match all methods.
+// The second parameter is the route to match (see the Routing section below)
+export const hello = DemoServer.defineRoute("GET", "/hello", async (ygg) => {
+ return new Response("Hello world!", { status: 200 });
+});
+```
+
+### Re-export all the routes from a single file
+
+```ts title="src/routes/index.ts"
+export * from "./hello";
+// repeat the above for each route file in your project
+```
+
+### Handle requests
+
+Once you have your router setup, simply call YggdrasilRouter.handleRequest
+to use it:
+
+```ts title="src/index.ts"
+import * as routes from "./routes";
+
+// This should ideally be defined outside your request handler
+const DemoRouter = new YggdrasilRouter(DemoServer, routes);
+
+// Additional required setup omitted for brevity
+
+// Inside DemoServer.handleRequest:
+return DemoRouter.handleRequest(ygg);
+```
+
+## Routing
+
+When you define a route, you need to specify a method and path. Requests
+that match the defined method and path will be handled by the route.
+
+### HTTP method
+
+The method can be any HTTP method, or * to match all methods.
+
+### Path
+
+#### Normalization
+
+Incoming requests match paths based on their normalized, relative paths.
+Paths must be exactly equal to match.
+
+For example, if you have no normalization configured, a route
+path `/abc` will match requests made to `/abc` but not `/ABC`, `/abc/`, or `/ABC/`.
+If you have lowercase normalization and trailing slash removal enabled, `/abc`
+will match requests made to `/abc`, `/ABC`, `/abc/`, and `/ABC/`.
+
+However, please keep in mind that your route configuration is assumed to already
+be normalized. For example, if you have lowercase normalization enabled, and
+define a route with path `/ABC`, it will never match, because all requests
+will have their paths converted to lowercase before matching.
+
+Since routes use the relative path, a route path `/abc` will match
+requests made to `/demo/abc` if the base url is `https://yggdrasil.jottocraft.com/demo`,
+for example.
+
+#### Variable segments
+
+It is possible to make segments variable so they can match any slug.
+To do this, simply prefix the segment with a dollar sign (`$`).
+
+For example, to match any arbitrary ID in the path `/posts/<any arbitrary ID>`,
+define the route path as `/posts/$postID`. Then, when handling the request,
+you can retrieve the post ID as `ygg.params.postID`.
+
+Variable segment names MUST be consistent between routes, or the
+behavior of which name will be used is undefined. For example, if you have
+routes `/posts/$postID` and `/posts/$PostID/likes`, the name of the entry
+in the `ygg.params` object is undefined.
+
+### Multiple matches
+
+YggdrasilRouter does not check
+every possible way to match a request. This creates the potential for
+requests to unexpectedly fail to match.
+
+#### Same method and path
+
+If you define multiple routes with the exact same method and path, the behavior
+for which will be called is undefined.
+
+#### Different method, same path
+
+If you define multiple routes with different methods, but the same path,
+YggdrasilRouter will call the route that matches the specific method
+used in the request. If no route is defined for the specific method,
+it will call the route that can match any method (*) if it exists.
+
+#### Different paths
+
+YggdrasilRouter only checks each path segment once. If it sees that a
+segment can be matched with either a variable segment or a literal match,
+it will prefer the literal match. This can lead to some potentially unexpected
+behavior, however. It's best to avoid allowing a route to be matched with different
+paths for this reason.
+
+For example, assume you have routes `/posts/$postId` and `/posts/$postId/likes`.
+Then, you create a new route to render a special post, e.g. `/posts/specialPost`.
+A request to `/posts/specialPost/likes` will fail to match because Yggdrasil Router
+sees and matches `posts` and `specialPost`, but doesn't see any `likes` segment
+under `specialPost`. It will not consider the possibility that `$postId` could
+be used to match `specialPost` to locate the intended route.
+
+YggdrasilRouter matches the path before the method, so if you have routes
+`GET /posts/$postId`, `POST /posts/$postId`, and `GET /posts/specialPost`,
+a request `POST /posts/specialPost` will fail because it took the literal
+path instead of the variable path, and there isn't a `POST` handler on the
+literal path.
+
+## Errors
+
+YggdrasilRouter can throw YggdrasilStatus objects when a route can't
+be matched, an invalid method is used, etc. Please see the "Error handling"
+page for documentation of these internal errors.
\ No newline at end of file
diff --git a/docs/docs/index.md b/docs/docs/index.md
index 64de153..0511c35 100644
--- a/docs/docs/index.md
+++ b/docs/docs/index.md
@@ -2,6 +2,70 @@
sidebar_position: 1
---
-# Hello world!
+# Getting started
-TODO: Write the docs
\ No newline at end of file
+Welcome to Yggdrasil Server! Yggdrasil Server is a modern JavaScript library
+for managing context, errors, and routing when handling and responding to
+HTTP requests.
+
+## Quickstart
+
+### Step 1: Install Yggdrasil Server
+
+```bash npm2yarn
+npm install @jottocraft/yggdrasil --save
+```
+
+
+### Step 2: Construct a YggdrasilServer instance
+
+```ts title="src/server.ts"
+import { YggdrasilServer } from "@jottocraft/yggdrasil";
+
+// Any arbitrary custom data to pass to your request handlers
+// e.g. environment variables, database bindings, etc.
+export type AppCtx = {
+ env: DemoEnv;
+ ctx: ExecutionContext;
+};
+
+export const DemoServer = new YggdrasilServer<AppCtx>();
+```
+
+### Step 3: Handle requests
+
+```ts title="src/index.ts"
+import { DemoServer } from "./server";
+
+export default {
+ async fetch(request: Request, env: DemoEnv, ctx: ExecutionContext) {
+ return DemoServer.handleRequest(request, async (ygg) => {
+ // Yggdrasil Server uses YggdrasilStatus objects to indicate errors
+ // that you can either catch yourself, or ignore to let Yggdrasil Server
+ // generate an error page for you.
+ if (ygg.pathname !== "/") throw ygg.status(404, "INVALID_PATHNAME");
+
+ // You can do whatever you want to handle the request here.
+
+ return new Response("Hello World!", {
+ status: 200
+ });
+ },
+ // Your custom request context, available as ygg.ctx() in request handlers.
+ {
+ env, ctx
+ },
+ // Yggdrasil Server options. These are specified here rather than in
+ // the YggdrasilServer object to support multi-tenancy.
+ {
+ debug: true
+ });
+ }
+};
+```
+
+## Explore more features
+
+The quickstart example shows how to get up and running with the basic
+functionality of Yggdrasil Server. To continue exploring more powerful
+features, head to the "Features" section in the sidebar.
\ No newline at end of file
diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js
index bba0588..b7bfe60 100644
--- a/docs/docusaurus.config.js
+++ b/docs/docusaurus.config.js
@@ -9,7 +9,7 @@
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Yggdrasil Server',
- tagline: 'A flexible JavaScript router.',
+ tagline: 'A simple and flexible TypeScript library for streamlining web request handling.',
favicon: '/docs/favicon.png',
// Set the production url of your site here
@@ -30,7 +30,7 @@
},
presets: [
- ["classic", { docs: { routeBasePath: '/' }, blog: false, theme: { customCss: './src/css/custom.css' } }]
+ ["classic", { docs: { routeBasePath: '/', remarkPlugins: [require("@docusaurus/remark-plugin-npm2yarn")] }, blog: false, theme: { customCss: './src/css/custom.css' } }]
],
themeConfig:
@@ -54,7 +54,13 @@
},
prism: {
theme: prismThemes.github,
- darkTheme: prismThemes.dracula
+ darkTheme: prismThemes.dracula,
+ additionalLanguages: ["bash"]
+ },
+ announcementBar: {
+ id: "yggdrasil_alpha",
+ content: "Yggdrasil Server is currently in alpha and is subject to change drastically. Please proceed at your own risk.",
+ isCloseable: false
}
}
};
diff --git a/docs/package.json b/docs/package.json
index acdf220..2403376 100644
--- a/docs/package.json
+++ b/docs/package.json
@@ -4,9 +4,9 @@
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
- "build": "docusaurus build",
+ "build": "rmdir /s /q dist && docusaurus build && mkdir dist && move build dist && move dist\\build dist\\docs",
"swizzle": "docusaurus swizzle",
- "deploy": "docusaurus deploy",
+ "deploy": "wrangler pages deploy dist --project-name yggdrasil-docs",
"clear": "docusaurus clear",
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
@@ -15,6 +15,7 @@
"dependencies": {
"@docusaurus/core": "3.5.2",
"@docusaurus/preset-classic": "3.5.2",
+ "@docusaurus/remark-plugin-npm2yarn": "^3.5.2",
"@mdx-js/react": "^3.0.0",
"clsx": "^2.0.0",
"prism-react-renderer": "^2.3.0",