ProjectEvergreen / greenwood

Greenwood is your workbench for the web, embracing web standards from the ground up to empower your stack from front to back.
https://www.greenwoodjs.io
MIT License
97 stars 9 forks source link

add support for configuring lang attribute in default template #558

Closed thescientist13 closed 2 years ago

thescientist13 commented 3 years ago

Type of Change

Summary

As part of the PR for #512, the question came up regarding default app templates and what the default HTML tags should, and in particular the lang attribute.

<html lang="en" prefix="og:http://ogp.me/ns#">

It is a required attribute, but it's also meant to be contextual to the language content of the project.

Details

My first thought would be that user's could provide a lang config property, and that we could swap out that part for them.

// greenwood.config.js
module.exports = {
  lang: "xx"
}

Then we would return the default template with their lang

<html lang="xx" prefix="og:http://ogp.me/ns#">

Open to other options, but I think it would be important to make this easy, but not also not sure how often someone would want to configure lang but not also be using their own app template? 🤔

mknee40 commented 3 years ago

Wouldn't just manually changing the lang attribute have the same effort as adding it in the configuration file? Im not sure how many templates you would be using, but even if you had 10 templates, this is still not going to take long to update. Does the language configuration affect anything other than the value in the html template, for example, any translation components?

thescientist13 commented 3 years ago

Yeah, that's definitely a good point regarding just writing it all in HTML as opposed to wrapping it up all in JavaScript somewhere. For example, the same could be said of being able to pass <meta> tags programmatically (an earlier design decision / solution pre v0.10.0) where as to your point, it would probably be just as easy now (arguably easier) to just write the plain HTML right in your own code.

It's definitely a question I have had in the back of my mind.

Plus, this would only account for our default app-template.html anyway so, it's a good question to say: how much work should be put into a potentially minimally used feature? (potentially). 🤔

thescientist13 commented 2 years ago

Not sure if this is worth it, along the lines of #851 ? Probably just recommend users set it themselves, or if it does need to be configurable, then that use case is likely in the scope of i18n which is a much larger conversation to be had.