SEO.LLMs.Entry (SEO v0.2.1)

Copy Markdown View Source

Represents a single resource entry in an llms.txt file.

Each entry belongs to a section and has a title, URL, optional description, and optional markdown content (for serving the resource as markdown).

Fields

  • :section — which H2 section this entry belongs to (e.g., "Docs", "Articles", "Optional")
  • :title — the link text
  • :url — the link target URL
  • :description — optional text after the link in llms.txt
  • :content — optional markdown body for serving the page as markdown. Can be a string or a zero-arity function for lazy loading.

Summary

Functions

Build an Entry struct from attributes, optionally merging with defaults.

Group a list of entries by their :section field into the tuple format that SEO.LLMs.render/1 expects.

Types

t()

@type t() :: %SEO.LLMs.Entry{
  content: String.t() | (-> String.t()) | nil,
  description: String.t() | nil,
  section: String.t() | nil,
  title: String.t() | nil,
  url: String.t() | nil
}

Functions

build(attrs, default \\ nil)

@spec build(SEO.attrs(), SEO.config()) :: t() | nil

Build an Entry struct from attributes, optionally merging with defaults.

group_by_section(entries)

@spec group_by_section([t()]) :: [SEO.LLMs.Provider.section()]

Group a list of entries by their :section field into the tuple format that SEO.LLMs.render/1 expects.

Returns a list of {section_name, entries} tuples where entries are {title, url} or {title, url, description} tuples.

Example

entries = [
  %SEO.LLMs.Entry{section: "Docs", title: "API", url: "/api"},
  %SEO.LLMs.Entry{section: "Docs", title: "Guide", url: "/guide", description: "Getting started"},
  %SEO.LLMs.Entry{section: "Optional", title: "FAQ", url: "/faq"}
]

SEO.LLMs.Entry.group_by_section(entries)
#=> [{"Docs", [{"API", "/api"}, {"Guide", "/guide", "Getting started"}]},
#=>  {"Optional", [{"FAQ", "/faq"}]}]