mirror of
https://github.com/only-cli/oc.git
synced 2026-09-15 10:40:56 +02:00
MDN renders its search results client-side, so 'oc mdn search' has gone through DuckDuckGo with a site: filter. But the page it renders gets its results from a public JSON endpoint, /api/v1/search, which returns the site's own ranking with a summary per result in one ~11KB response. A new 'api' shortcut shape names such an endpoint and which response fields hold the list, title, URL, and snippet; the response becomes the same synthetic results page a Sphinx search produces and rides the normal render path, so 'do <n>' follows a result. First view is ~520 tokens and works for any site whose search answers as JSON.
10 lines
687 B
JSON
10 lines
687 B
JSON
{
|
|
"domain": "developer.mozilla.org",
|
|
"commands": {
|
|
"js": { "open": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/{page}", "args": ["page"] },
|
|
"css": { "open": "https://developer.mozilla.org/en-US/docs/Web/CSS/{page}", "args": ["page"] },
|
|
"doc": { "open": "https://developer.mozilla.org/en-US/docs/{path}", "args": ["path"] },
|
|
"search": { "api": "https://developer.mozilla.org/api/v1/search?q={query}&locale=en-US", "page": "https://developer.mozilla.org/en-US/search?q={query}", "results": "documents", "fields": { "title": "title", "url": "mdn_url", "text": "summary" }, "total": "metadata.total.value", "args": ["query"] }
|
|
}
|
|
}
|