File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -43,3 +43,6 @@ The `fetch` generator fetches a URL (using [unjs/ofetch](https://ofetch.unjs.io)
43
43
## Arguments
44
44
45
45
- ` url ` : The URL to fetch from
46
+
47
+ > [ !TIP]
48
+ > You can start url with ` gh: ` to use github contents!
Original file line number Diff line number Diff line change @@ -4,9 +4,19 @@ export const fetch = defineGenerator({
4
4
name : "fetch" ,
5
5
async generate ( { args } ) {
6
6
const { $fetch } = await import ( "ofetch" ) ;
7
- const body = await $fetch ( args . url ) ;
7
+
8
+ let url = args . url ;
9
+ if ( ! url ) {
10
+ throw new Error ( "URL is required!" ) ;
11
+ }
12
+ if ( url . startsWith ( "gh:" ) ) {
13
+ url = `https://raw.githubusercontent.com/${ url . slice ( 3 ) } ` ;
14
+ }
15
+
16
+ const contents = await $fetch ( url ) ;
17
+
8
18
return {
9
- contents : body ,
19
+ contents,
10
20
} ;
11
21
} ,
12
22
} ) ;
You can’t perform that action at this time.
0 commit comments