code wiki / _hdl_build / _pe_seohead.nx

_pe_seohead.nx source

↩ module page · 64 lines · 2558 B

1// AUTHORED BY THE NISHI BUILDER (pattern: TEMPLATE_TABLE) -- table-driven fragment renderer, no Claude logic 2// raw=0 slots ESCAPED (hs_escape), raw=1 verbatim (pre-sanitized rich). -1 = unknown kind, refused. 3import "nx_syscalls.nx" 4import "nx_html_sanitize.nx" 5func _pe_seohead_cat(out: *u8, o: i64, cap: i64, s: *u8) -> i64 { 6 var k: i64 = 0 7 var p: i64 = o 8 while s[k] != (0 as u8) { if p < cap { out[p] = s[k]; p = p + 1 } k = k + 1 } 9 return p 10} 11func _pe_seohead_put(out: *u8, o: i64, cap: i64, src: *u8, n: i64, raw: i64) -> i64 { 12 if raw == 1 { 13 var k: i64 = 0 14 var p: i64 = o 15 while k < n { if p < cap { out[p] = src[k]; p = p + 1 } k = k + 1 } 16 return p 17 } 18 return o + hs_escape(src, n, ((out as i64) + o) as *u8, cap - o) 19} 20func _pe_seohead_one(kind: i64, pay: *u8, plen: i64, out: *u8, cap: i64) -> i64 { 21 if kind == 1 { 22 var o1: i64 = _pe_seohead_cat(out, 0, cap, "<title>") 23 o1 = _pe_seohead_put(out, o1, cap, pay, plen, 0) 24 o1 = _pe_seohead_cat(out, o1, cap, "</title>") 25 return o1 26 } 27 if kind == 2 { 28 var o2: i64 = _pe_seohead_cat(out, 0, cap, "<meta name=\"description\" content=\"") 29 o2 = _pe_seohead_put(out, o2, cap, pay, plen, 0) 30 o2 = _pe_seohead_cat(out, o2, cap, "\">") 31 return o2 32 } 33 if kind == 3 { 34 var o3: i64 = _pe_seohead_cat(out, 0, cap, "<meta property=\"og:title\" content=\"") 35 o3 = _pe_seohead_put(out, o3, cap, pay, plen, 0) 36 o3 = _pe_seohead_cat(out, o3, cap, "\">") 37 return o3 38 } 39 if kind == 4 { 40 var o4: i64 = _pe_seohead_cat(out, 0, cap, "<meta property=\"og:description\" content=\"") 41 o4 = _pe_seohead_put(out, o4, cap, pay, plen, 0) 42 o4 = _pe_seohead_cat(out, o4, cap, "\">") 43 return o4 44 } 45 if kind == 5 { 46 var o5: i64 = _pe_seohead_cat(out, 0, cap, "<meta property=\"og:image\" content=\"") 47 o5 = _pe_seohead_put(out, o5, cap, pay, plen, 0) 48 o5 = _pe_seohead_cat(out, o5, cap, "\">") 49 return o5 50 } 51 if kind == 6 { 52 var o6: i64 = _pe_seohead_cat(out, 0, cap, "<link rel=\"canonical\" href=\"") 53 o6 = _pe_seohead_put(out, o6, cap, pay, plen, 0) 54 o6 = _pe_seohead_cat(out, o6, cap, "\">") 55 return o6 56 } 57 if kind == 7 { 58 var o7: i64 = _pe_seohead_cat(out, 0, cap, "<meta property=\"og:type\" content=\"") 59 o7 = _pe_seohead_put(out, o7, cap, pay, plen, 0) 60 o7 = _pe_seohead_cat(out, o7, cap, "\">") 61 return o7 62 } 63 return 0 - 1 64}