Classes
HasMetadata
Protocol for objects that have metadata and content attributes.
HasMetadata
Protocol for objects that have metadata and content attributes.
ProtocolAttributes
| Name | Type | Description |
|---|---|---|
metadata |
dict[str, Any] |
|
content |
str |
PageComputedMixin
Mixin providing cached computed properties for pages.
This mixin handles expensive operations that…
PageComputedMixin
Mixin providing cached computed properties for pages.
This mixin handles expensive operations that are cached after first access:
- meta_description - SEO-friendly description
- reading_time - Estimated reading time
- excerpt - Content excerpt
Methods 3
meta_description
property
Generate SEO-friendly meta description (computed once, cached).
Creates descri…
meta_description
property def meta_description(self: HasMetadata) -> str
Generate SEO-friendly meta description (computed once, cached).
Creates description by:
- Using explicit 'description' from metadata if available
- Otherwise generating from content by stripping HTML and truncating
- Attempting to end at sentence boundary for better readability
The result is cached after first access, so multiple template uses (meta tag, og:description, twitter:description) only compute once.
Returns
Meta description text (max 160 chars)str
—
reading_time
property
Calculate reading time in minutes (computed once, cached).
Estimates reading t…
reading_time
property def reading_time(self: HasMetadata) -> int
Calculate reading time in minutes (computed once, cached).
Estimates reading time based on word count at 200 words per minute. Strips HTML before counting to ensure accurate word count.
The result is cached after first access for efficient repeated use.
Returns
Reading time in minutes (minimum 1)int
—
excerpt
property
Extract content excerpt (computed once, cached).
Creates a 200-character excer…
excerpt
property def excerpt(self: HasMetadata) -> str
Extract content excerpt (computed once, cached).
Creates a 200-character excerpt from content by:
- Stripping HTML tags
- Truncating to length
- Respecting word boundaries (doesn't cut words in half)
- Adding ellipsis if truncated
The result is cached after first access for efficient repeated use.
Returns
Excerpt text with ellipsis if truncatedstr
—