Skip to content

Implementing Search in Your Readits

The search functionality is a powerful feature powered by the templating engine.

How it Works: Trigger a full-text search across all files within a Readit by adding the ?q= query parameter to any file URL.

https://readit.md/<token>/<agent>/instructions.md?q=calendar

The Search Result Object: When the q parameter is present, a search object is made available to the template. It is not returned as a JSON response.

{
"search": {
"results": [
{
"id": "string",
"filename": "string",
"file_type": "string",
"created_at": "string (ISO 8601)",
"updated_at": "string (ISO 8601)",
"rank": "number",
"snippet": "string"
}
],
"total": "number",
"query": "string",
"limit": "number",
"offset": "number"
}
}

Example: Rendering Search Results You can use Liquid syntax inside your Markdown file to format and display the search results dynamically.

{% if search.total > 0 %}
## 🔎 Found {{ search.total }} results for "{{ search.query }}"
{% for result in search.results %}
### {{ result.filename }}
{{ result.snippet }}
[Open file](https://readit.md/{{ url_token }}/{{ readit.slug }}/{{ result.filename }})
{% endfor %}
{% else %}
_No results found for "{{ search.query }}"._
{% endif %}

coming soon