Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for symbolized hashes for frontmatter defaults in the Ruby initializer DSL #704

Closed
ayushn21 opened this issue Jan 26, 2023 · 1 comment · Fixed by #944 · May be fixed by #886
Closed

Add support for symbolized hashes for frontmatter defaults in the Ruby initializer DSL #704

ayushn21 opened this issue Jan 26, 2023 · 1 comment · Fixed by #944 · May be fixed by #886
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@ayushn21
Copy link
Member

Bridgetown Version: 1.2

Current behavior

Frontmatter defaults can be specified in the bridgetown.config.yml as:

defaults:
  -
    scope: 
      path: "excluded_files/**/*"
    values: 
      sitemap: false 

To use this functionality in the Ruby DSL, only string keys can be used:

config.defaults << {
  "scope" => { "path" => "excluded_files/**/*" },
  "values" => { "sitemap" => false }
}

Expected behavior

The ability to use symbolized keys would be more "Ruby":

config.defaults << {
  scope: { path: "excluded_files/**/*" },
  values: { sitemap: false }
}
@ayushn21 ayushn21 added the bug Something isn't working label Jan 26, 2023
@jaredcwhite jaredcwhite added the good first issue Good for newcomers label Feb 2, 2023
@bcgoss
Copy link

bcgoss commented Feb 4, 2023

Notes from research: config.defaults returns an array. The code in this example uses << to push an additional default into the array. This new default is plain ruby hash, not a HashWithDotAccess or a HashWithIndifferentAccess. At some point we may want to use site.config.defaults.map!(&:with_dot_access) to ensure all the defaults are the expected type.

Update 2/7, a simple puts at https://github.com/bridgetownrb/bridgetown/blob/main/bridgetown-core/lib/bridgetown-core/frontmatter_defaults.rb#L187 revealed that the objects in site.config["defaults'] is actually a HashWithDotAccess`, so there's something else at play.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
3 participants