Skip to content

Commit

Permalink
feat: add type attribite to renderScript helper
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeraS committed Jan 29, 2024
1 parent 35affb3 commit 17fd1e6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ interface Script {
defer?: boolean;
async?: boolean;
crossOrigin?: '' | 'anonymous' | 'use-credentials';
type?: 'importmap' | 'module' | string;
}
```

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface Script {
defer?: boolean;
async?: boolean;
crossOrigin?: '' | 'anonymous' | 'use-credentials';
type?: 'importmap' | 'module' | (string & {});
}

export interface Stylesheet {
Expand Down
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ export function attrs(obj: Attributes): string {
const OG_META_PREFIX = 'og:';

export function getRenderHelpers(params: {nonce?: string}): RenderHelpers {
function renderScript({src, defer, async, crossOrigin}: Script) {
function renderScript({src, defer, async, crossOrigin, type}: Script) {
return src
? `<script ${attrs({
src,
defer,
async,
crossorigin: crossOrigin,
nonce: params.nonce,
type,
})}></script>`
: '';
}
Expand Down

0 comments on commit 17fd1e6

Please sign in to comment.