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 additional options for Location title generation #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bensyverson
Copy link
Contributor

Summary

This PR offers a few new ways to specify titles for HTML pages.

Discussion

Currently, there's a titleSeparator property in the head method exposed by Publish for use in the Plot DSL:

HTML(
    .head(for: index, on: context.site, titleSeparator: " : "),
)

The format of the title is fixed: you'll get Location.title and Site.name separated by a separator (About Us | Website).

This PR changes the API of that head method to expose a titleStyle property which takes an enum:

public enum HTMLTitleStyle {
    case locationTitle
    case titleAndSiteName(separator: String)
    case fixed(string: String)
}

The default remains the same—if you haven't specified titleSeparator in your head method, it will continue to output Location | Site. However, with this PR you have some flexibility:

  • locationTitle will output just the Location's title:
<title>About Us</title>
  • titleAndSiteName(separator: String) is the existing default:
<title>About Us | Website</title>
  • fixed(string: String) lets you override the title in the template:
`<title>Template override</title>

The updated API can be used as such:

HTML(
    .head(for: index, on: context.site, titleStyle: .fixed("Introducing LazerPow")),
)

Implications

Because this PR changes the API for the head method, it can/will break existing Publish projects. I think there's a way to supply the updated API to Xcode's "fixit" functionality, but I haven't had time to research that just yet.

On the positive side, the enum makes it easy to add new title generation techniques in the future. There are some other ways of addressing the same underlying need, but this seems like a good compromise of simplicity vs expressivity.

Thanks for reading!

@JohnSundell JohnSundell added the awaiting update Awaiting an update from the PR author label Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting update Awaiting an update from the PR author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants