File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @frontside/staticalize" ,
3- "version" : " 0.2.0 " ,
3+ "version" : " 0.2.2 " ,
44 "exports" : {
55 "." : " ./mod.ts" ,
66 "./cli" : " ./main.ts"
Original file line number Diff line number Diff line change @@ -159,6 +159,19 @@ function useDownloader(opts: DownloaderOptions): Operation<Downloader> {
159159 }
160160 }
161161
162+ let withContents = selectAll ( "[content]" , html ) ;
163+ for ( let element of withContents ) {
164+ let attr = String ( element . properties . content ) ;
165+ if ( attr . startsWith ( host . origin ) ) {
166+ yield * downloader . download ( attr , source ) ;
167+ let url = new URL ( attr ) ;
168+ url . host = base . host ;
169+ url . port = base . port ;
170+ url . protocol = base . protocol ;
171+ element . properties . content = url . href ;
172+ }
173+ }
174+
162175 yield * call ( async ( ) => {
163176 let destdir = dirname ( destpath ) ;
164177 await ensureDir ( destdir ) ;
Original file line number Diff line number Diff line change @@ -193,13 +193,15 @@ describe("staticalize", () => {
193193<html>
194194 <head>
195195 <link rel="canonical" href="${ host } "/>
196- <script src="${ host } main.js"/>
196+ <meta property="og:url" content="${ host } image.png"/>
197+ <script src="${ host } main.js"></script>
197198 </head>
198199 <body></body>
199200</html>
200201` ;
201202 app . get ( "/" , ( c ) => c . html ( html ) )
202203 . get ( "/alt" , ( c ) => c . html ( html ) )
204+ . get ( "/image.png" , ( c ) => c . text ( "" ) )
203205 . get ( "/main.js" , ( c ) => c . text ( "console.log('hi')" ) )
204206 . get ( ...sitemap ( [ "/" ] ) ) ;
205207
@@ -215,6 +217,9 @@ describe("staticalize", () => {
215217 await expect ( content ( "test/dist/index.html" ) ) . resolves . toMatch (
216218 `<script src="https://fs.com/main.js">` ,
217219 ) ;
220+ await expect ( content ( "test/dist/index.html" ) ) . resolves . toMatch (
221+ `<meta property="og:url" content="https://fs.com/image.png">` ,
222+ ) ;
218223 } ) ;
219224} ) ;
220225
You can’t perform that action at this time.
0 commit comments