Skip to content

Commit

Permalink
feat: add posthtml-fetch types
Browse files Browse the repository at this point in the history
  • Loading branch information
cossssmin committed Feb 8, 2024
1 parent b8eeb4c commit 426ce9a
Showing 1 changed file with 156 additions and 0 deletions.
156 changes: 156 additions & 0 deletions src/index.d.ts
@@ -1,3 +1,4 @@
import type {Options as GotOptions} from 'got';
import type {StringifyOptions} from 'query-string';
import type {CoreBeautifyOptions} from 'js-beautify';
import type {Options as MarkdownItOptions} from 'markdown-it';
Expand Down Expand Up @@ -737,29 +738,41 @@ declare namespace MaizzleFramework {
*/
tag?: string;
};

/**
Configure the <fetch> tag.
@default {}
*/
fetch?: PostHTMLFetchConfig;
}

interface BuildConfig {
/**
Templates configuration.
*/
templates: TemplatesConfig;

/**
Tailwind CSS configuration.
*/
tailwind?: TailwindConfig;

/**
[DEPRECATED] Layouts configuration.
*/
layouts?: LayoutsConfig;

/**
Components configuration.
*/
components?: ComponentsConfig;

/**
PostHTML configuration.
*/
posthtml?: PostHTMLConfig;

/**
Configure PostCSS
*/
Expand All @@ -785,13 +798,15 @@ declare namespace MaizzleFramework {
*/
plugins?: any[];
};

/**
Browsersync configuration.
When you run the `maizzle serve` command, Maizzle uses [Browsersync](https://browsersync.io/)
to start a local development server and open a directory listing of your emails in your default browser.
*/
browsersync?: BrowserSyncConfig;

/**
Configure how build errors are handled when developing with the Maizzle CLI.
Expand Down Expand Up @@ -1900,6 +1915,147 @@ declare namespace MaizzleFramework {
config: Config;
};

interface PostHTMLFetchConfig {
/**
Supported tag names.
Only tags from this array will be processed by the plugin.
@default ['fetch', 'remote']
@example
```
module.exports = {
build: {
posthtml: {
fetch: {
tags: ['get']
}
}
}
}
```
*/
tags?: string[];

/**
String representing the attribute name containing the URL to fetch.
@default 'url'
@example
```
module.exports = {
build: {
posthtml: {
fetch: {
attribute: 'from'
}
}
}
}
```
*/
attribute?: string;

/**
`posthtml-fetch` uses `got` to fetch data.
You can pass options directly to it, inside the `got` object.
@default {}
@example
```
module.exports = {
build: {
posthtml: {
got: {
prefixUrl: '...'
}
}
}
}
```
*/
got?: GotOptions;

/**
When set to `true`, this option will preserve the `tag`, i.e. `<fetch>` around the response body.
@default false
@example
```
module.exports = {
build: {
posthtml: {
fetch: {
preserveTag: true
}
}
}
}
```
*/
preserveTag?: boolean;

/**
Pass options to `posthtml-expressions`.
@default {}
@example
```
module.exports = {
build: {
posthtml: {
fetch: {
expressions: {
delimiters: ['[[', ']]']
}
}
}
}
}
```
*/
expressions?: ExpressionsConfig;

/**
List of plugins that will be called after/before receiving and processing `locals`.
@default {}
@example
```
module.exports = {
build: {
posthtml: {
fetch: {
plugins: {
after(tree) {
// Your plugin implementation
},
before: [
tree => {
// Your plugin implementation
},
tree => {
// ..
}
]
}
}
}
}
}
```
*/
plugins?: {
after?: (tree: any) => void;
before?: Array<(tree: any) => void>;
}

Check failure on line 2056 in src/index.d.ts

View workflow job for this annotation

GitHub Actions / build (14)

Expected a semicolon.

Check failure on line 2056 in src/index.d.ts

View workflow job for this annotation

GitHub Actions / build (16)

Expected a semicolon.
}

/**
Compile an HTML string with Maizzle.
Expand Down

0 comments on commit 426ce9a

Please sign in to comment.