Platform
Resources
Pricing
Sign in
Get started
Fabian Iwand
Web developer and autodidact with an interest in creative coding.
Workspace
Fork
Published
2 collections
By
Fabian Iwand
Edited
Sep 18, 2022
Importers
5 stars
Insert cell
Insert cell
Insert cell
md
`
> For example, ${
await
link
(
'@martien/abc'
)
} does not exists, while ${
await
link
(
'@martien/x-matrix'
)
} does exist.
`
Insert cell
Insert cell
md
`
> For example, ${
linkDelayed
(
'@martien/abc'
)
} does not exists, while ${
linkDelayed
(
'@martien/x-matrix'
)
} does exist.
`
Insert cell
Insert cell
async
function
exists
(
slug
)
{
return
fetch
(
`https://api.observablehq.com/${
slug
}.js`
,
{
method
:
'HEAD'
}
)
.
then
(
r
=>
r
.
ok
)
.
catch
(
(
)
=>
false
)
;
}
Insert cell
async
function
link
(
slug
)
{
return
exists
(
slug
)
.
then
(
r
=>
r
?
html
`<a href="/${
slug
}">${
slug
}`
:
slug
)
;
}
Insert cell
function
linkDelayed
(
slug
)
{
const
el
=
html
`<a>${
slug
}`
;
exists
(
slug
)
.
then
(
found
=>
{
if
(
found
)
el
.
href
=
`/${
slug
}`
}
)
;
return
el
;
}
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Listed in...
Observable Things
Fabian Iwand
Tools & Techniques
Fabian Iwand
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
exists
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
link
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
linkDelayed
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML