Skip to content

Commit 8cb9f5d

Browse files
basic TypeScript callouts within reference docs
1 parent 59c98ce commit 8cb9f5d

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

src/pages/docs/reference/appendix.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
---
22
layout: docs
3-
order: 5
3+
order: 4
44
tocHeading: 2
55
---
66

77
# Appendix
88

9+
## Types
10+
11+
In addition to [supporting TypeScript](/docs/resources/typescript/) out of the box, Greenwood also exports a number of useful types that you can use if authoring your configuration files, plugins, etc as TypeScript. You can find all available types for the CLI [here](https://github.com/ProjectEvergreen/greenwood/blob/master/packages/cli/src/types/index.d.ts) including types for configuration, content as data APIs, graph and compilation objects, plugins, and more. Each of Greenwood's plugin will also provide their own set of types within their package at _src/types/index.d.ts_.
12+
13+
For example, here is how to author a TypeScript based configuration file:
14+
15+
```ts
16+
import type { Config } from "@greenwood/cli";
17+
18+
const config: Config = {
19+
prerender: true,
20+
};
21+
22+
export default config;
23+
```
24+
925
## Build Output
1026

1127
Greenwood produces a consistent build output that typically mirrors the source directory as it persists all file naming, albeit with hashes included. For static content, this can be used by static hosting sites with no additional configuration, on serverless hosting with our adapters, or self-hosted.
@@ -88,7 +104,7 @@ It is fine-tuned for creating Light and Shadow DOM based custom elements. The fu
88104
- `customElements.define`
89105
- `attachShadow`
90106
- `innerHTML`
91-
- ` [get|set|has]Attribute`
107+
- `[get|set|has]Attribute`
92108
- `<template>` / DocumentFragment
93109
- `addEventListener` (as a no-op)
94110
- `CSSStyleSheet` (all methods act as no-ops on the server)

src/pages/docs/reference/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This section details all the supported configuration options available with **Gr
1111
Below is a _greenwood.config.js_ file reflecting default values:
1212

1313
```js
14+
/** @type {import('@greenwood/cli').Config} */
1415
export default {
1516
activeContent: false,
1617
basePath: "",

src/pages/docs/reference/plugins-api.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ tocHeading: 2
1010

1111
Below are the various plugin types you can use to extend and further customize Greenwood.
1212

13+
> Types are available for all plugin constructs. Please see our [reference docs](/docs/reference/appendix/#types) to learn more.
14+
1315
## Overview
1416

1517
Each plugin must return a function that has the following three properties:
@@ -72,6 +74,7 @@ An adapter plugin is simply an `async` function that gets invoked by the Greenwo
7274
<app-ctc-block variant="snippet">
7375

7476
```js
77+
/** @type {import("@greenwood/cll").AdapterPlugin} */
7578
const greenwoodPluginMyPlatformAdapter = () => {
7679
return {
7780
type: "adapter",
@@ -93,7 +96,7 @@ An adapter plugin is simply an `async` function that gets invoked by the Greenwo
9396

9497
### Example
9598

96-
The most common use case is to "shim" in a hosting platform handler function in front of Greenwood's, which is based on two parameters of `Request` / `Response`. In addition, producing any hosting provided specific metadata is also doable at this stage.
99+
The most common use case is to "shim" in a hosting platform handler function in front of Greenwood's, which is based on standard `Request` / `Response` objects. In addition, producing any hosting provided specific metadata is also doable at this stage.
97100

98101
Here is an example of the "generic adapter" created for Greenwood's own internal test suite.
99102

@@ -224,6 +227,7 @@ Your plugin might look like this:
224227
* acme-theme-pack.js
225228
* package.json
226229
*/
230+
/** @type {import("@greenwood/cll").ContextPlugin} */
227231
export function myContextPlugin() {
228232
return {
229233
type: "context",
@@ -259,6 +263,7 @@ This plugin supports providing an array of "paired" URL objects that can either
259263
<app-ctc-block variant="snippet" heading="my-copy-plugin.js">
260264
261265
```js
266+
/** @type {import("@greenwood/cll").CopyPlugin} */
262267
export function myCopyPlugin() {
263268
return {
264269
type: "copy",
@@ -344,6 +349,7 @@ This plugin expects to be given a path to a module that exports a function to ex
344349
<app-ctc-block variant="snippet" heading="my-renderer-plugin.js">
345350
346351
```js
352+
/** @type {import("@greenwood/cll").RendererPlugin} */
347353
const greenwoodPluginMyCustomRenderer = () => {
348354
return {
349355
type: "renderer",
@@ -416,6 +422,7 @@ A [resource "interface"](https://github.com/ProjectEvergreen/greenwood/tree/mast
416422
// lifecycles go here
417423
}
418424

425+
/** @type {import("@greenwood/cll").ResourcePlugin} */
419426
export function myExampleResourcePlugin(options = {}) {
420427
return {
421428
type: "resource",
@@ -715,6 +722,7 @@ Simply use the `provider` method to return an array of Rollup plugins:
715722

716723
const packageJson = JSON.parse(fs.readFileSync("./package.json", "utf-8"));
717724

725+
/** @type {import("@greenwood/cll").RollupPlugin} */
718726
export function myRollupPlugin() {
719727
const now = new Date().now();
720728

@@ -798,6 +806,7 @@ The below is an excerpt of [Greenwood's internal LiveReload server](https://gith
798806
}
799807
}
800808

809+
/** @type {import("@greenwood/cll").ServerPlugin} */
801810
export function myServerPlugin(options = {}) {
802811
return {
803812
type: "server",
@@ -824,6 +833,7 @@ This plugin supports providing an array of "page" objects that will be added as
824833
<app-ctc-block variant="snippet" heading="my-source-plugin.js">
825834
826835
```js
836+
/** @type {import("@greenwood/cll").SourcePlugin} */
827837
export const customExternalSourcesPlugin = () => {
828838
return {
829839
type: "source",

0 commit comments

Comments
 (0)