nx_sitemap.nx
buildroot/runtime/nx_sitemap.nx
about
sitemap.nx -- XML Sitemap 0.9 builder.
Specification: sitemaps.org (Google/Yahoo/MSN 2005 joint draft).
Every search crawler uses it to discover pages it might not
reach via link-following. Referenced from robots.txt and served
at /sitemap.xml or /sitemap-index.xml.
Skeleton:
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">
<url>
<loc>https://example.com/foo</loc>
<lastmod>2026-04-22</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
...
</urlset>
Soft caps (per spec): 50,000 URLs per sitemap, 50 MiB uncompressed.
For larger sites use a sitemap index (not implemented here yet;
a future sitemap_index.nx will compose this).
Invariants:
S1 loc is required; lastmod/changefreq/priority optional.
S2 lastmod is date-only format YYYY-MM-DD (from unix_sec
via civil_date.nx). Sitemaps accept ISO 8601 but
date-only is canonical and smaller.
S3 changefreq values: always, hourly, daily, weekly, monthly,
yearly, never. We surface them as constants; caller picks.
S4 Stream builder: sitemap_begin -> sitemap_url* -> sitemap_end.
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_html_escape.nxnx_civil_date.nx
imported by: nobody (leaf or entry point)
structs
| none |
consts
| 42 | const SM_MAGIC_4096: i64 = 4096 |
| 43 | const SM_MAGIC_1777000000: i64 = 1777000000 |
| 45 | const SM_ERR_SHORT: i64 = -1 |
| 47 | const SM_FREQ_ALWAYS: i64 = 1 |
| 48 | const SM_FREQ_HOURLY: i64 = 2 |
| 49 | const SM_FREQ_DAILY: i64 = 3 |
| 50 | const SM_FREQ_WEEKLY: i64 = 4 |
| 51 | const SM_FREQ_MONTHLY: i64 = 5 |
| 52 | const SM_FREQ_YEARLY: i64 = 6 |
| 53 | const SM_FREQ_NEVER: i64 = 7 |
| 54 | const SM_FREQ_NONE: i64 = 0 |
functions
| 56 | func sm_put(out: *u8, cap: i64, off: i64, src: *u8, n: i64) -> i64 |
| 66 | func sm_put_escaped(out: *u8, cap: i64, off: i64, calls 1: html_escape |
| 74 | func sm_put_date(out: *u8, cap: i64, off: i64, unix_sec: i64) -> i64 |
| 94 | func sm_put_freq(out: *u8, cap: i64, off: i64, freq: i64) -> i64 calls 1: sm_put |
| 112 | func sitemap_begin(out: *u8, cap: i64, off: i64) -> i64 calls 1: sm_put |
| 126 | func sitemap_url(out: *u8, cap: i64, off: i64, |
| 174 | func sitemap_end(out: *u8, cap: i64, off: i64) -> i64 |
| 179 | func main() -> i64 |