Skip to content

Conversation

@eelcoj
Copy link
Contributor

@eelcoj eelcoj commented Dec 30, 2025

Closes #81

  • Deprecate Perron::Site.data in favor of Content::Data::ClassName.all
  • Add Content::Data namespace for data resources (e.g., Content::Data::Authors)
  • Implement .all and .find class methods on Perron::Data
  • Support class_name option for associations with Data classes
  • Support has_many with explicit IDs via {association_name}_ids in metadata/frontmatter, e.g. author_ids: [rails-designer, cam] (bit like Rail' has_and_belongs_to_many)

Usage:

belongs_to :author, class_name: "Content::Data::Authors" 
has_many :writers, class_name: "Content::Author"
Content::Data::Users.all 
Content::Data::Users.find

Deprecation:
Perron::Site.data.users is deprecated in favour of Content::Data::Users.all—which is more conventional.

- Add Content::Data namespace for data resources (e.g., Content::Data::Authors)
- Implement .all and .find class methods on Perron::Data
- Support class_name option for associations with Data classes
- Deprecate Perron::Site.data in favor of Content::Data::ClassName.all

Usage:
  ```
  belongs_to :author, class_name: "Content::Data::Authors"
  has_many :writers, class_name: "Content::Data::Authors"

  Content::Data::Users.all
  Content::Data::Users.find
  ```

Deprecation:
  `Perron::Site.data.users` is deprecated. Use `Content::Data::Users.all` instead.
… in metadata

Usage:
```
  # In frontmatter:
  author_ids: [rails-designer, cam]

  # In model:
  has_many :authors, class_name: "Content::Data::Authors"

  # Returns authors matching the IDs in author_ids array
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support associations with Perron::Data

2 participants