Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22419282
sitemap.xml.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
784 B
Referenced Files
None
Subscribers
None
sitemap.xml.tsx
View Options
import
type
{
Context
}
from
"koa"
;
import
{
Page
}
from
"@sealcode/sealgen"
;
export
const
actionName
=
"Sitemap"
;
async
function
generateSitemap
(
ctx
:
Context
)
{
const
pages
=
await
ctx
.
$app
.
collections
.
pages
.
list
(
ctx
.
$context
).
fetch
();
let
xml
=
`<?xml version="1.0" encoding="UTF-8"?>\n`
;
xml
+=
`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n`
;
for
(
const
page
of
pages
.
items
)
{
xml
+=
` <url>\n <loc>
${
ctx
.
origin
.
replace
(
/\/$/
,
""
)
}${
page
.
get
(
"url"
)
}
</loc>\n </url>\n`
;
}
xml
+=
`</urlset>\n`
;
return
xml
;
}
export
default
new
(
class
SitemapPage
extends
Page
{
async
canAccess
()
{
return
{
canAccess
:
true
,
message
:
""
};
}
async
render
(
ctx
:
Context
)
{
ctx
.
set
(
"Content-Type"
,
"application/xml"
);
return
generateSitemap
(
ctx
);
}
})();
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Sat, Nov 28, 02:20 (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1205655
Default Alt Text
sitemap.xml.tsx (784 B)
Attached To
Mode
rREWRITE Configurable rewriter
Attached
Detach File
Event Timeline