Skip to content

Conversation

@gerteck
Copy link
Member

@gerteck gerteck commented Dec 24, 2025

What is the purpose of this pull request?

  • Documentation update
  • Bug fix
  • Feature addition or enhancement
  • Code maintenance
  • DevOps
  • Improve developer experience
  • Others, please explain:

Overview of changes:

Addresses #2761

Enhances by adding functionality for MarkBind to generate other file types while retaining nunjucks variable functionality, i.e. from .md files into .XXX files that might not be .html files.

Summary of Changes

  • Added an optional fileExtension property that can be specified in site.json > pages.
  • createPage method updated to use the fileExtension to determine output file path.
    • Additionally, it was refactored: previously, output file path created by directly reusing the page’s source path, assuming a clean, relative path. New change computes the path relative to the site root and normalize it before generating the output path, so that all output files are placed in the correct location under the output directory, even if the source path is absolute or contains .., and makes the behavior consistent across operating systems.
  • Update passing along the fileExtension property through the build pipeline.
  • Rename outputPageHtml to writeOutputFile to reflect the new process.

Anything you'd like to highlight/discuss:

  • Documentation updates added
  • Currently, to make it more polished, can add support for intra-site link validation. Because with this, even if you add a link to the resource, it will be flagged as invalid as it doesn't recognize non .md or .html links.

Testing instructions:

Proposed commit message: (wrap lines at 72 characters)

Add support for custom file type generation

Custom file type generation with Nunjucks variable processing
Configured in site.json.

Additionally, add jsdoc and docs for template property
Ensure correct relative file paths, add fileExtension property
Add testcase for site.json
...


Checklist: ☑️

  • Updated the documentation for feature additions and enhancements
  • Added tests for bug fixes or features
  • Linked all related issues
  • No unrelated changes

Reviewer checklist:

Indicate the SEMVER impact of the PR:

  • Major (when you make incompatible API changes)
  • Minor (when you add functionality in a backward compatible manner)
  • Patch (when you make backward compatible bug fixes)

At the end of the review, please label the PR with the appropriate label: r.Major, r.Minor, r.Patch.

Breaking change release note preparation (if applicable):

  • To be included in the release note for any feature that is made obsolete/breaking

Give a brief explanation note about:

  • what was the old feature that was made obsolete
  • any replacement feature (if any), and
  • how the author should modify his website to migrate from the old feature to the replacement feature (if possible).

@codecov
Copy link

codecov bot commented Dec 24, 2025

Codecov Report

❌ Patch coverage is 80.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.29%. Comparing base (024b2ce) to head (30cbc5d).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
packages/core/src/Page/index.ts 76.92% 3 Missing ⚠️
packages/core/src/Page/PageVueServerRenderer.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2762      +/-   ##
==========================================
+ Coverage   61.65%   62.29%   +0.63%     
==========================================
  Files         130      130              
  Lines        7167     7182      +15     
  Branches     1480     1580     +100     
==========================================
+ Hits         4419     4474      +55     
+ Misses       2685     2644      -41     
- Partials       63       64       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances MarkBind to support generating non-HTML file types (such as .json or .txt) from markdown source files while retaining Nunjucks variable functionality. This allows users to generate dynamic configuration files and other text-based assets using MarkBind's template system.

Key Changes:

  • Added optional fileExtension property to page configurations in site.json
  • Refactored output path computation in createPage to normalize paths relative to site root before generating output paths
  • Modified page generation pipeline to handle non-HTML files by processing only variables and skipping HTML-specific processing (frontmatter, layouts, scripts, Vue SSR)

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/core/src/Site/index.ts Added fileExtension to type definitions; refactored createPage to compute output paths based on configured file extension
packages/core/src/Site/SiteConfig.ts Added fileExtension property to SiteConfigPage type
packages/core/src/Page/index.ts Added early return for non-HTML files in generate method; renamed outputPageHtml to writeOutputFile with separate handling for HTML vs non-HTML files
packages/core/src/Page/PageVueServerRenderer.ts Updated method call from outputPageHtml to writeOutputFile
packages/core/src/Page/PageConfig.ts Added documentation comment for template property
docs/userGuide/syntax/links.md Updated documentation to reflect that markdown links are converted to configured output extension
docs/userGuide/siteJsonFile.md Documented the new fileExtension configuration property
docs/userGuide/addingPages.md Added comprehensive section explaining custom file type generation with examples and key limitations
docs/userGuide/customFileTypes/sampleTxt.md Sample text file demonstrating Nunjucks variable usage
docs/userGuide/customFileTypes/sampleJson.md Sample JSON file demonstrating Nunjucks variable usage
docs/site.json Added page configurations for sample custom file type examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gerteck gerteck merged commit 82ebe98 into MarkBind:master Dec 26, 2025
10 checks passed
@github-actions github-actions bot added the r.Minor Version resolver: increment by 0.1.0 label Dec 26, 2025
@gerteck
Copy link
Member Author

gerteck commented Dec 26, 2025

Closes #2761

@damithc
Copy link
Contributor

damithc commented Dec 26, 2025

Tested, and works as expected e.g., https://git-mastery.github.io/exercises-directory/exercises.json
Thanks for the quick solution, @gerteck 💯

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

Labels

r.Minor Version resolver: increment by 0.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants