Skip to content

Automate frontmatter generation for easier contribution #34

@sirkitree

Description

@sirkitree

Currently, contributors need to manually add frontmatter to their markdown files, which can be a barrier to contribution and lead to formatting issues. This was highlighted in PR #32 where the required frontmatter was missing.

Proposed Solution

Create an automated system to generate and add frontmatter to markdown files when they're submitted in a PR. This would make contributing easier and ensure consistent formatting.

Options to Consider

  1. GitHub Action (Recommended)
  • Automatically runs on PRs
  • Extracts title from first H1 heading
  • Generates description from first paragraph
  • Sets date to PR creation date
  • Determines discipline/contentType from file path
  • Generates tags based on content analysis
  • No setup required from contributors
  1. Eleventy Transform
  • Injects frontmatter during build if missing
  • Works locally during development
  • Might miss some metadata that could be extracted from PR context
  • Requires build to see results
  1. Pre-commit Hook
  • Works locally before commit
  • Requires setup from contributors
  • May not have access to all context (like PR date)
  1. Template Files
  • Simple solution
  • Requires manual copying
  • No automation
  • Could still be forgotten

Implementation Details for GitHub Action Approach

The action would:

  1. Trigger on PR creation/update
  2. Scan for new/modified .md files
  3. Check for missing frontmatter
  4. Generate frontmatter using:
    • Title: Extract from first H1 (# Title)
    • Description: Use first paragraph or generate from content
    • Date: PR creation date
    • Layout: Always "markdown.njk"
    • Discipline: Extract from file path
    • ContentType: Extract from file path
    • Tags: Generate based on content analysis

Questions to Consider

  1. Should we auto-commit the changes or just comment on the PR?
  2. How sophisticated should the tag generation be?
  3. Should we validate the generated frontmatter against our requirements?
  4. Should we provide a way for contributors to override the automation?

Next Steps

  1. Choose preferred approach
  2. Create proof of concept
  3. Test with sample content
  4. Document the automation process
  5. Update contribution guidelines

Let's discuss which approach would work best for our team and contributors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or requestgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions