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

Make it possible to add custom attributes to the body tag #1542

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

fekete-robert
Copy link
Collaborator

Make it possible to add custom attributes to the body tag, from the page frontmatter, similarly to body_class.

@deining
Copy link
Collaborator

deining commented Jun 7, 2023

I like the idea. However, the parameter you want to add is closely related to the (undocumented) body_class parameter (see your PR 1541). So why don't we combine both approaches? I envision to have parameter body attributes in the frontmatter and giving a map like structure there. E.g.:

JSON:

{
	"body_attributes": {
		"class": "class_value",
		"attrib_2": "value",
		"attrib_n": "value"
	}
}

YAML:

body_attribute:
  class: value
  attrib_2: value
  attrib_n: value

This way, we had one single way to add the class attribute and possibly one or more custom attributes, too. WDYT?

@fekete-robert
Copy link
Collaborator Author

To be honest, it seems not many users missed the body_class feature so far, and I suspect even less will need the attributes feature - it's just something that will come handy for the pagefind integration.
While I agree that combining the two features would make sense and result in a nicer config, I think that the separate parameters are easier to configure, and combining them might be an overkill.

But if you think it's needed for the PR to be accepted I'll do it when I have some free time.

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.

None yet

2 participants