Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F149
rehype-images.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
695 B
Referenced Files
None
Subscribers
None
rehype-images.ts
View Options
import
type
{
Element
,
Root
}
from
"npm:@types/hast"
;
import
type
{
VFile
}
from
"vfile"
;
import
{
visit
}
from
"unist-util-visit"
;
import
{
join
}
from
"@std/path"
;
import
{
asset
}
from
"#/assets.ts"
;
export
default
function
rehypeImages
()
{
return
async
function
(
tree
:
Root
,
file
:
VFile
)
{
const
images
:
Element
[]
=
[];
visit
(
tree
,
"element"
,
function
(
node
)
{
if
(
node
.
tagName
===
"img"
)
{
images
.
push
(
node
);
}
});
for
(
const
node
of
images
)
{
node
.
properties
.
src
=
await
asset
(
join
(
"#src"
,
"articles"
,
file
.
data
.
slug
as
string
,
node
.
properties
.
src
as
string
,
),
);
}
};
}
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Mon, Oct 26, 02:57 (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
58
Default Alt Text
rehype-images.ts (695 B)
Attached To
Mode
rB blog
Attached
Detach File
Event Timeline