[{"data":1,"prerenderedAt":781},["ShallowReactive",2],{"content-en-\u002Fapi\u002Fdata-sources":3},{"id":4,"title":5,"body":6,"description":774,"extension":194,"jsonLd":775,"meta":776,"navigation":207,"path":777,"schemaRole":775,"seo":778,"stem":779,"__hash__":780},"content_en\u002Fapi\u002Fdata-sources.md","dataSources \u002F loadDataSources",{"type":7,"value":8,"toc":759},"minimark",[9,13,35,41,69,77,91,187,190,228,331,338,345,421,447,451,459,478,481,485,539,543,564,568,595,599,662,668,677,726,730,755],[10,11,5],"h1",{"id":12},"datasources-loaddatasources",[14,15,16,17,21,22,25,26,30,31,34],"p",{},"Load external data files (",[18,19,20],"strong",{},"YAML \u002F JSON \u002F CSV",") ",[18,23,24],{},"only through the public API"," and bind them as template variables. DSL ",[27,28,29],"code",{},"import"," \u002F ",[27,32,33],{},"require"," cannot read files.",[14,36,37,38],{},"Version: ",[18,39,40],{},"0.11.0",[42,43,48],"pre",{"className":44,"code":45,"language":46,"meta":47,"style":47},"language-ts shiki shiki-themes github-dark-high-contrast","import { renderServer, loadDataSources, build } from '@b4moss\u002Fhyogen-md'\n","ts","",[27,49,50],{"__ignoreMap":47},[51,52,55,58,62,65],"span",{"class":53,"line":54},"line",1,[51,56,29],{"class":57},"sWyjQ",[51,59,61],{"class":60},"sMAXC"," { renderServer, loadDataSources, build } ",[51,63,64],{"class":57},"from",[51,66,68],{"class":67},"sTRMh"," '@b4moss\u002Fhyogen-md'\n",[70,71,73,74],"h2",{"id":72},"option-datasources","Option ",[27,75,76],{},"dataSources",[14,78,79,80,83,84,30,87,90],{},"Pass a ",[18,81,82],{},"variable name → file path"," map in ",[27,85,86],{},"renderServer",[27,88,89],{},"build"," options.",[42,92,94],{"className":44,"code":93,"language":46,"meta":47,"style":47},"const result = await renderServer('.\u002Fpage.md', {}, {\n  root: '.\u002Fsite',\n  dataSources: {\n    site: '.\u002Fdata\u002Fsite.yaml',\n    products: '.\u002Fdata\u002Fproducts.json',\n    rows: '.\u002Fdata\u002Frows.csv',\n  },\n})\n",[27,95,96,124,136,142,153,164,175,181],{"__ignoreMap":47},[51,97,98,101,105,108,111,115,118,121],{"class":53,"line":54},[51,99,100],{"class":57},"const",[51,102,104],{"class":103},"sCcAr"," result",[51,106,107],{"class":57}," =",[51,109,110],{"class":57}," await",[51,112,114],{"class":113},"sj_SG"," renderServer",[51,116,117],{"class":60},"(",[51,119,120],{"class":67},"'.\u002Fpage.md'",[51,122,123],{"class":60},", {}, {\n",[51,125,127,130,133],{"class":53,"line":126},2,[51,128,129],{"class":60},"  root: ",[51,131,132],{"class":67},"'.\u002Fsite'",[51,134,135],{"class":60},",\n",[51,137,139],{"class":53,"line":138},3,[51,140,141],{"class":60},"  dataSources: {\n",[51,143,145,148,151],{"class":53,"line":144},4,[51,146,147],{"class":60},"    site: ",[51,149,150],{"class":67},"'.\u002Fdata\u002Fsite.yaml'",[51,152,135],{"class":60},[51,154,156,159,162],{"class":53,"line":155},5,[51,157,158],{"class":60},"    products: ",[51,160,161],{"class":67},"'.\u002Fdata\u002Fproducts.json'",[51,163,135],{"class":60},[51,165,167,170,173],{"class":53,"line":166},6,[51,168,169],{"class":60},"    rows: ",[51,171,172],{"class":67},"'.\u002Fdata\u002Frows.csv'",[51,174,135],{"class":60},[51,176,178],{"class":53,"line":177},7,[51,179,180],{"class":60},"  },\n",[51,182,184],{"class":53,"line":183},8,[51,185,186],{"class":60},"})\n",[14,188,189],{},"Map keys become template variable names:",[42,191,195],{"className":192,"code":193,"language":194,"meta":47,"style":47},"language-md shiki shiki-themes github-dark-high-contrast","# {{ site.title }}\n\n{{#each products.items}}\n- {{ this.name }}\n{{\u002Feach}}\n","md",[27,196,197,203,209,214,223],{"__ignoreMap":47},[51,198,199],{"class":53,"line":54},[51,200,202],{"class":201},"s-VM4","# {{ site.title }}\n",[51,204,205],{"class":53,"line":126},[51,206,208],{"emptyLinePlaceholder":207},true,"\n",[51,210,211],{"class":53,"line":138},[51,212,213],{"class":60},"{{#each products.items}}\n",[51,215,216,220],{"class":53,"line":144},[51,217,219],{"class":218},"s_sBn","-",[51,221,222],{"class":60}," {{ this.name }}\n",[51,224,225],{"class":53,"line":155},[51,226,227],{"class":60},"{{\u002Feach}}\n",[229,230,231,244],"table",{},[232,233,234],"thead",{},[235,236,237,241],"tr",{},[238,239,240],"th",{},"Item",[238,242,243],{},"Rule",[245,246,247,264,275,290,311],"tbody",{},[235,248,249,253],{},[250,251,252],"td",{},"Paths",[250,254,255,256,259,260,263],{},"Relative to ",[27,257,258],{},"options.root"," (or ",[27,261,262],{},".doc_root"," \u002F cwd when omitted)",[235,265,266,269],{},[250,267,268],{},"Keys",[250,270,271,274],{},[18,272,273],{},"No constraints"," (any string)",[235,276,277,280],{},[250,278,279],{},"Size limit",[250,281,282,285,286,289],{},[18,283,284],{},"5MB per file"," (",[27,287,288],{},"data_source_too_large"," when exceeded)",[235,291,292,295],{},[250,293,294],{},"Remote URLs",[250,296,297,285,300,30,303,306,307,310],{},[18,298,299],{},"Unsupported",[27,301,302],{},"http:\u002F\u002F",[27,304,305],{},"https:\u002F\u002F"," → ",[27,308,309],{},"load_failed",")",[235,312,313,316],{},[250,314,315],{},"Client",[250,317,318,319,322,323,326,327,330],{},"Passing to ",[27,320,321],{},"renderClient"," throws ",[27,324,325],{},"data_sources_on_client"," (empty ",[27,328,329],{},"{}"," is treated as omitted)",[70,332,334,335],{"id":333},"function-loaddatasources","Function ",[27,336,337],{},"loadDataSources",[14,339,340,341,344],{},"You can load files first and merge into ",[27,342,343],{},"context"," yourself.",[42,346,348],{"className":44,"code":347,"language":46,"meta":47,"style":47},"const fromFiles = await loadDataSources(\n  { site: '.\u002Fdata\u002Fsite.yaml' },\n  { root: '.\u002Fsite' },\n)\n\nawait renderServer('.\u002Fpage.md', { ...fromFiles, extra: 1 })\n",[27,349,350,367,377,386,391,395],{"__ignoreMap":47},[51,351,352,354,357,359,361,364],{"class":53,"line":54},[51,353,100],{"class":57},[51,355,356],{"class":103}," fromFiles",[51,358,107],{"class":57},[51,360,110],{"class":57},[51,362,363],{"class":113}," loadDataSources",[51,365,366],{"class":60},"(\n",[51,368,369,372,374],{"class":53,"line":126},[51,370,371],{"class":60},"  { site: ",[51,373,150],{"class":67},[51,375,376],{"class":60}," },\n",[51,378,379,382,384],{"class":53,"line":138},[51,380,381],{"class":60},"  { root: ",[51,383,132],{"class":67},[51,385,376],{"class":60},[51,387,388],{"class":53,"line":144},[51,389,390],{"class":60},")\n",[51,392,393],{"class":53,"line":155},[51,394,208],{"emptyLinePlaceholder":207},[51,396,397,400,402,404,406,409,412,415,418],{"class":53,"line":166},[51,398,399],{"class":57},"await",[51,401,114],{"class":113},[51,403,117],{"class":60},[51,405,120],{"class":67},[51,407,408],{"class":60},", { ",[51,410,411],{"class":57},"...",[51,413,414],{"class":60},"fromFiles, extra: ",[51,416,417],{"class":103},"1",[51,419,420],{"class":60}," })\n",[422,423,424,432,441],"ul",{},[425,426,427,428,431],"li",{},"Exported only from ",[27,429,430],{},"@b4moss\u002Fhyogen-md"," (server package)",[425,433,434,437,438],{},[18,435,436],{},"Not"," exported from ",[27,439,440],{},"@b4moss\u002Fhyogen-md\u002Fclient",[425,442,443,444,446],{},"Same parse rules, size limit, and remote rejection as the ",[27,445,76],{}," option",[70,448,450],{"id":449},"context-merge-order","Context merge order",[14,452,453,454,30,456,458],{},"For ",[27,455,86],{},[27,457,89],{},", shallow-merge in this order (later wins):",[460,461,462,468,473],"ol",{},[425,463,464,465],{},"Result of ",[27,466,467],{},"loadDataSources(dataSources)",[425,469,470,471],{},"Caller ",[27,472,343],{},[425,474,475],{},[27,476,477],{},"serverContext",[14,479,480],{},"Front matter is applied even later inside rendering.",[70,482,484],{"id":483},"formats","Formats",[229,486,487,497],{},[232,488,489],{},[235,490,491,494],{},[238,492,493],{},"Extension",[238,495,496],{},"Value bound to the variable",[245,498,499,512,529],{},[235,500,501,506],{},[250,502,503],{},[27,504,505],{},".json",[250,507,508,511],{},[27,509,510],{},"JSON.parse"," result (object \u002F array \u002F primitive)",[235,513,514,522],{},[250,515,516,30,519],{},[27,517,518],{},".yaml",[27,520,521],{},".yml",[250,523,524,525,528],{},"Result from the ",[27,526,527],{},"yaml"," package",[235,530,531,536],{},[250,532,533],{},[27,534,535],{},".csv",[250,537,538],{},"Header row required → array of objects (all fields are strings)",[540,541,542],"h3",{"id":527},"YAML",[422,544,545,552,555,558],{},[425,546,547,548,551],{},"Types (dates, numbers, booleans, ",[27,549,550],{},"null",", …) follow the library defaults",[425,553,554],{},"Alias \u002F anchor are allowed",[425,556,557],{},"Duplicate keys follow the parser default (later wins)",[425,559,560,561],{},"Invalid YAML → ",[27,562,563],{},"parse_error",[540,565,567],{"id":566},"csv-strict","CSV (strict)",[422,569,570,579,582,587,592],{},[425,571,572,573,30,576,310],{},"RFC 4180 subset (comma, double quotes, ",[27,574,575],{},"\\r\\n",[27,577,578],{},"\\n",[425,580,581],{},"Blank rows are skipped",[425,583,584,585],{},"Column-count mismatch → ",[27,586,563],{},[425,588,589],{},[18,590,591],{},"No BOM stripping",[425,593,594],{},"TSV \u002F other delimiters are unsupported",[540,596,598],{"id":597},"common-errors","Common errors",[229,600,601,611],{},[232,602,603],{},[235,604,605,608],{},[238,606,607],{},"Situation",[238,609,610],{},"Code",[245,612,613,622,634,644,653],{},[235,614,615,618],{},[250,616,617],{},"Empty file",[250,619,620],{},[27,621,563],{},[235,623,624,627],{},[250,625,626],{},"Unsupported extension",[250,628,629,285,631,310],{},[27,630,563],{},[27,632,633],{},"details.format",[235,635,636,639],{},[250,637,638],{},"Missing file",[250,640,641],{},[27,642,643],{},"file_not_found",[235,645,646,649],{},[250,647,648],{},"Remote URL",[250,650,651],{},[27,652,309],{},[235,654,655,658],{},[250,656,657],{},"Over 5MB",[250,659,660],{},[27,661,288],{},[70,663,665,666],{"id":664},"behavior-in-build","Behavior in ",[27,667,89],{},[14,669,670,672,673,676],{},[27,671,76],{}," is loaded ",[18,674,675],{},"once before the entry loop"," and shared across all entries.",[42,678,680],{"className":44,"code":679,"language":46,"meta":47,"style":47},"await build({\n  input: '.\u002Fpages\u002F**\u002F*.md',\n  outDir: '.\u002Fout',\n  dataSources: { config: '.\u002Fdata\u002Fconfig.yaml' },\n})\n",[27,681,682,692,702,712,722],{"__ignoreMap":47},[51,683,684,686,689],{"class":53,"line":54},[51,685,399],{"class":57},[51,687,688],{"class":113}," build",[51,690,691],{"class":60},"({\n",[51,693,694,697,700],{"class":53,"line":126},[51,695,696],{"class":60},"  input: ",[51,698,699],{"class":67},"'.\u002Fpages\u002F**\u002F*.md'",[51,701,135],{"class":60},[51,703,704,707,710],{"class":53,"line":138},[51,705,706],{"class":60},"  outDir: ",[51,708,709],{"class":67},"'.\u002Fout'",[51,711,135],{"class":60},[51,713,714,717,720],{"class":53,"line":144},[51,715,716],{"class":60},"  dataSources: { config: ",[51,718,719],{"class":67},"'.\u002Fdata\u002Fconfig.yaml'",[51,721,376],{"class":60},[51,723,724],{"class":53,"line":155},[51,725,186],{"class":60},[70,727,729],{"id":728},"see-also","See also",[422,731,732,738,743,749],{},[425,733,734],{},[735,736,86],"a",{"href":737},"\u002Fen\u002Fapi\u002Frender-server",[425,739,740],{},[735,741,89],{"href":742},"\u002Fen\u002Fapi\u002Fbuild",[425,744,745],{},[735,746,748],{"href":747},"\u002Fen\u002Fapi\u002Ftypes-and-options","Types and options",[425,750,751],{},[735,752,754],{"href":753},"\u002Fen\u002Fapi\u002Ferror-codes","Error codes",[756,757,758],"style",{},"html pre.shiki code .sWyjQ, html code.shiki .sWyjQ{--shiki-default:#FF9492}html pre.shiki code .sMAXC, html code.shiki .sMAXC{--shiki-default:#F0F3F6}html pre.shiki code .sTRMh, html code.shiki .sTRMh{--shiki-default:#ADDCFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sCcAr, html code.shiki .sCcAr{--shiki-default:#91CBFF}html pre.shiki code .sj_SG, html code.shiki .sj_SG{--shiki-default:#DBB7FF}html pre.shiki code .s-VM4, html code.shiki .s-VM4{--shiki-default:#91CBFF;--shiki-default-font-weight:bold}html pre.shiki code .s_sBn, html code.shiki .s_sBn{--shiki-default:#FFB757}",{"title":47,"searchDepth":126,"depth":126,"links":760},[761,763,765,766,771,773],{"id":72,"depth":126,"text":762},"Option dataSources",{"id":333,"depth":126,"text":764},"Function loadDataSources",{"id":449,"depth":126,"text":450},{"id":483,"depth":126,"text":484,"children":767},[768,769,770],{"id":527,"depth":138,"text":542},{"id":566,"depth":138,"text":567},{"id":597,"depth":138,"text":598},{"id":664,"depth":126,"text":772},"Behavior in build",{"id":728,"depth":126,"text":729},"Load external YAML \u002F JSON \u002F CSV via the public API and bind them as template variables",null,{},"\u002Fapi\u002Fdata-sources",{"title":5,"description":774},"api\u002Fdata-sources","kHUok9k-mQkfg-MlxDrUT1YPbJKrbqpt4MF7yl-KZaI",1788678619180]