Skip to content

Add frontmatter template setting#10

Open
smichniak wants to merge 2 commits intowatsonbox:masterfrom
smichniak:frontmatter-template-source
Open

Add frontmatter template setting#10
smichniak wants to merge 2 commits intowatsonbox:masterfrom
smichniak:frontmatter-template-source

Conversation

@smichniak
Copy link
Copy Markdown

Title

Add support for custom Handlebars templates in activity frontmatter

Description

This PR introduces the ability to customize the frontmatter of imported activities using Handlebars templates, similar to how activity content is currently templated. This offers greater flexibility than the existing list-based property configuration.

Changes

  • Settings: Added a "Front matter template" setting in the "Activity" section.
  • Renderer: Updated ActivityRenderer to use the provided Handlebars template for frontmatter if configured; falls back to the existing property list if not.
  • UI: Added a text area in SettingsTab for users to input their custom frontmatter template with a helpful description and link to Handlebars docs.
  • Tests: Added unit tests to verify that custom frontmatter templates render correctly and respect the available activity data.
  • Documentation: Updated README.md with instructions and an example of how to use the new frontmatter templating feature.

Example

Users can now define frontmatter like this to include dynamic tags, custom URLs, or conditional fields:

tags: [sport/activity, sport/{{sport_type}}]
id: {{id}}
name: "{{name}}"
start_date: {{start_date}}
icon: {{icon}}
url: https://www.strava.com/activities/{{id}}

@watsonbox
Copy link
Copy Markdown
Owner

Thanks a lot for this interesting idea. It would indeed give some extra flexibility.

When I was reviewing the code, though, the duplicated template rendering gave me an idea: what if it were possible to simply add front matter to the content template itself?

Perhaps we could detect when the content template starts with ---, remove it, then add the id property (I'd like to keep this mandatory to indentify the activity in case it's useful for future features, plus any other properties listed in the current metadata config, but then omit the trailing --- assuming that the content would render its own properties and close the front matter.

I'm not 100% sure of the approach, and yes it's a little more hidden as a feature, but specifying front matter in the content template actually strikes me as fairly natural, and could be documented clearly in the readme as well of course.

What do you think?

@watsonbox watsonbox added the enhancement New feature or request label Jan 11, 2026
@smichniak
Copy link
Copy Markdown
Author

What do you think?

That sounds good, it makes sense to keep the rendering in one place and one setting. It should be intuitive to place the front matter with --- in the setting box, just like editing a raw note. I have made the changes that implement this. Did you have something like this in mind?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants