Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22398308
html.tsx
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
html.tsx
View Options
import
type
{
HTMLArgs
,
HTMLOptions
}
from
"@sealcode/sealgen"
;
import
{
tempstreamAsync
}
from
"tempstream"
;
import
type
{
Readable
}
from
"stream"
;
import
{
toKebabCase
}
from
"js-convert-case"
;
import
{
DEFAULT_HTML_LANG
}
from
"./config.js"
;
import
{
default_navbar
}
from
"./routes/common/navbar.js"
;
import
{
defaultHead
}
from
"./defaultHead.js"
;
const
default_html_options
:
Partial
<
HTMLOptions
>
=
{
showFooter
:
true
,
showBottomNavbar
:
true
,
loadHamburgerMenu
:
true
,
loadSearchModal
:
true
,
};
export
default
function
html
({
ctx
,
title
,
body
,
htmlOptions
=
{},
makeHead
=
defaultHead
,
metaImage
,
canonicalPath
,
css_clumps
=
[],
description
,
hideNavigation
=
false
,
}
:
HTMLArgs
)
:
Readable
{
htmlOptions
=
{
...
default_html_options
,
...
htmlOptions
};
ctx
.
set
(
"content-type"
,
htmlOptions
.
canHaveStreams
&&
ctx
.
get
(
"accept"
).
includes
(
"text/vnd.turbo-stream.html"
)
?
"text/vnd.turbo-stream.html"
:
"text/html;charset=utf-8"
);
const
controllers
:
string
[]
=
[];
if
(
htmlOptions
.
autoRefreshCSS
)
{
controllers
.
push
(
"refresh-styles"
);
controllers
.
push
(
"refresh-on-ts-changes"
);
}
return
tempstreamAsync
/* HTML */
` <!DOCTYPE html>
<html
lang="
${
htmlOptions
.
language
||
DEFAULT_HTML_LANG
}
"
class="title--
${
typeof
title
==
"string"
?
toKebabCase
(
title
)
:
""
}
"
>
<head>
${
makeHead
({
ctx
,
title
:
title
,
htmlOptions
:
{
...
htmlOptions
}
,
metaImage,
canonicalPath,
css_clumps,
description,
})}
</head>
<body
data-controller="
${
controllers
.
join
(
" "
)
}
"
class="
${
(
htmlOptions
?
.
bodyClasses
||
[]).
join
(
" "
)
}
"
>
${
!
hideNavigation
?
(
htmlOptions
?
.
navbar
||
default_navbar
)(
ctx
)
:
""
}
${
body
}
</body>
</html>`
;
}
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Nov 27, 17:21 (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1208286
Default Alt Text
html.tsx (1 KB)
Attached To
Mode
rREWRITE Configurable rewriter
Attached
Detach File
Event Timeline