[{"data":1,"prerenderedAt":482,"buildId":483},["ShallowReactive",2],{"docs:\u002Fguide":3},{"page":4,"section":17,"document":18,"credits":11,"prev":11,"next":480},{"id":5,"path":6,"file":7,"title":8,"sourceTitle":9,"description":10,"tagline":10,"eyebrow":11,"credits":11,"keywords":12,"icon":13,"layout":14,"sidebar":15,"toc":15,"kind":11,"group":11,"navigation":15,"order":16},"index","\u002Fguide","guide\u002Findex.md","Introduction","Introduction to whoasks","whoasks reads each request's Accept header, .md twin URL or ?format= and answers the same URL as HTML, Markdown or JSON.",null,[],"i-lucide-book-open","article",true,1,"guide",{"nodes":19,"toc":472},[20,24,32,40,129,138,144,147,182,190,196,216,310,316,411,417,420,452,458],[21,22,23],"p",{},"A page is written for people. An agent that fetches it gets markup to strip, and a program wants data. whoasks answers each request in the form its reader can use, at the same URL.",[25,26,31],"h2",{"id":27,"anchor":28},"the-three-forms",{"label":29,"icon":30},"Section titled \"The three forms\"","#","The three forms",[21,33,34,35,39],{},"A form is a shape an answer can take. Each form has a name, a list of media types, and sometimes an ",[36,37,38],"code",{},"ext"," suffix.",[41,42,43,63],"table",{},[44,45,46],"thead",{},[47,48,49,53,56,59],"tr",{},[50,51,52],"th",{},"Form",[50,54,55],{},"For",[50,57,58],{},"Media types",[50,60,61],{},[36,62,38],{},[64,65,66,85,112],"tbody",{},[47,67,68,74,77,82],{},[69,70,71],"td",{},[36,72,73],{},"html",[69,75,76],{},"People, browsers",[69,78,79],{},[36,80,81],{},"text\u002Fhtml",[69,83,84],{},"none",[47,86,87,92,95,107],{},[69,88,89],{},[36,90,91],{},"markdown",[69,93,94],{},"Agents",[69,96,97,100,101,100,104],{},[36,98,99],{},"text\u002Fmarkdown",", ",[36,102,103],{},"text\u002Fx-markdown",[36,105,106],{},"text\u002Fplain",[69,108,109],{},[36,110,111],{},".md",[47,113,114,119,122,127],{},[69,115,116],{},[36,117,118],{},"json",[69,120,121],{},"Programs",[69,123,124],{},[36,125,126],{},"application\u002Fjson",[69,128,84],{},[21,130,131,132,137],{},"A layer can add more forms. See ",[133,134,136],"a",{"href":135},"\u002Fguide\u002Flayers#add-a-form","Add a form",".",[25,139,143],{"id":140,"anchor":141},"how-a-request-asks",{"label":142,"icon":30},"Section titled \"How a request asks\"","How a request asks",[21,145,146],{},"whoasks checks three things in order to make its pick:",[148,149,150,161,171],"ol",{},[151,152,153,154,157,158,137],"li",{},"A twin URL. ",[36,155,156],{},"\u002Fdocs\u002Fguide.md"," asks for the Markdown of ",[36,159,160],{},"\u002Fdocs\u002Fguide",[151,162,163,166,167,170],{},[36,164,165],{},"?format=",". ",[36,168,169],{},"\u002Fdocs\u002Fguide?format=md"," asks for the same form. It is for a client that cannot set headers.",[151,172,173,174,177,178,181],{},"The ",[36,175,176],{},"Accept"," header. ",[36,179,180],{},"Accept: text\u002Fmarkdown"," asks for Markdown.",[21,183,184,185,189],{},"When the request states no preference, the answer is the first form the route offers. For a page, that default offer is HTML. See ",[133,186,188],{"href":187},"\u002Fguide\u002Fnegotiation","Negotiation"," for all seven rules.",[25,191,195],{"id":192,"anchor":193},"the-pieces",{"label":194,"icon":30},"Section titled \"The pieces\"","The pieces",[21,197,198,201,202,100,205,208,209,212,213,137],{},[36,199,200],{},"whoasks()"," returns a site with three methods (",[36,203,204],{},"ask",[36,206,207],{},"respond",", and ",[36,210,211],{},"handle",") plus ",[36,214,215],{},"forms",[41,217,218,228],{},[44,219,220],{},[47,221,222,225],{},[50,223,224],{},"Piece",[50,226,227],{},"What it does",[64,229,230,240,250,260,270,286,300],{},[47,231,232,237],{},[69,233,234],{},[36,235,236],{},"whoasks(...layers)",[69,238,239],{},"Merges the layers and returns a site",[47,241,242,247],{},[69,243,244],{},[36,245,246],{},"site.handle(request, next)",[69,248,249],{},"Goes in front of a whole app. Converts its HTML pages to Markdown when a request picks Markdown",[47,251,252,257],{},[69,253,254],{},[36,255,256],{},"site.respond(request, renders)",[69,258,259],{},"Answers one route, from one value per form",[47,261,262,267],{},[69,263,264],{},[36,265,266],{},"site.ask(request)",[69,268,269],{},"Returns the pick alone, without building a response",[47,271,272,277],{},[69,273,274],{},[36,275,276],{},"whoasks\u002Fh3",[69,278,279,282,283,285],{},[36,280,281],{},"middleware(site)",", which plugs ",[36,284,211],{}," into an h3 app",[47,287,288,293],{},[69,289,290],{},[36,291,292],{},"whoasks\u002Fcore",[69,294,295,296,299],{},"The same ",[36,297,298],{},"whoasks"," with no converter and no imports",[47,301,302,307],{},[69,303,304],{},[36,305,306],{},"mdream(options)",[69,308,309],{},"The default converter, with your options",[25,311,315],{"id":312,"anchor":313},"which-one-you-need",{"label":314,"icon":30},"Section titled \"Which one you need\"","Which one you need",[41,317,318,331],{},[44,319,320],{},[47,321,322,325,328],{},[50,323,324],{},"You have",[50,326,327],{},"Use",[50,329,330],{},"Page",[64,332,333,349,365,382,397],{},[47,334,335,338,343],{},[69,336,337],{},"A site of HTML pages",[69,339,340,342],{},[36,341,211],{},", once, in front of the app",[69,344,345],{},[133,346,348],{"href":347},"\u002Fguide\u002Fpages","Pages",[47,350,351,354,359],{},[69,352,353],{},"A route that returns data",[69,355,356,358],{},[36,357,207],{}," in that route",[69,360,361],{},[133,362,364],{"href":363},"\u002Fguide\u002Fapi-routes","API routes",[47,366,367,370,378],{},[69,368,369],{},"Both",[69,371,372,373,375,376],{},"Both. A route that calls ",[36,374,207],{}," works behind ",[36,377,211],{},[69,379,380],{},[133,381,364],{"href":363},[47,383,384,387,391],{},[69,385,386],{},"Your own response code that only needs the decision",[69,388,389],{},[36,390,204],{},[69,392,393],{},[133,394,396],{"href":395},"\u002Freference\u002Fapi","API reference",[47,398,399,402,405],{},[69,400,401],{},"A content source or a framework to plug in",[69,403,404],{},"A layer",[69,406,407],{},[133,408,410],{"href":409},"\u002Fguide\u002Flayers","Layers",[25,412,416],{"id":413,"anchor":414},"what-it-leaves-out",{"label":415,"icon":30},"Section titled \"What it leaves out\"","What it leaves out",[21,418,419],{},"These choices are deliberate:",[421,422,423,429,434,440],"ul",{},[151,424,425,426,428],{},"It does not read the User-Agent. Two clients with the same ",[36,427,176],{}," get the same answer, unless a layer says otherwise.",[151,430,431,433],{},[36,432,211],{}," never answers 406. A request that allows nothing offered gets the page as HTML.",[151,435,436,437,439],{},"The only adapter in the package is h3. Any other runtime calls ",[36,438,211],{}," directly.",[151,441,442,443,446,447,451],{},"No Nuxt module, no ",[36,444,445],{},"llms.txt"," generator, and no agent text format. ",[133,448,450],{"href":449},"\u002Fguide\u002Flayers#not-included","Not included"," shows how to build each.",[25,453,457],{"id":454,"anchor":455},"next",{"label":456,"icon":30},"Section titled \"Next\"","Next",[21,459,460,461,465,466,468,469,471],{},"Read ",[133,462,464],{"href":463},"\u002Fguide\u002Finstallation","Installation",", then ",[133,467,348],{"href":347}," for a site or ",[133,470,364],{"href":363}," for a data route.",[473,475,476,477,478,479],{"id":27,"depth":474,"text":31},2,{"id":140,"depth":474,"text":143},{"id":192,"depth":474,"text":195},{"id":312,"depth":474,"text":315},{"id":413,"depth":474,"text":416},{"id":454,"depth":474,"text":457},{"path":463,"title":464,"description":481},"Install whoasks, put it in front of an h3, Nitro, Hono or Cloudflare Workers app, and check with curl that Markdown comes back.",1796579200811,"78c9ee36-381e-45a5-bdf8-02819f0a7eb0"]