Skip to content
Discussion options

You must be logged in to vote

This works:

(eleventy.config.ts)

import { renderToStaticMarkup } from 'react-dom/server';

export default (config) => {
  config.addExtension(['ts', 'tsx'], { key: '11ty.js' });

  config.addTransform('compile tsx pages', function (content) {
    if (
      this.page.templateSyntax === 'tsx' &&
      this.page.outputFileExtension === 'html'
    ) {
      return `<!doctype html>${renderToStaticMarkup(content)}`;
    } else {
      return content;
    }
  });

  return {
    dir: { ... },
    templateFormats: ['md', 'ts', 'tsx'],
  };
};

(package.json)

{
  "type": "module",
  "devDependencies": {
    "@11ty/eleventy": "^3.1.2",
    "@types/react": "^19.1.10",
    "react": "^19.1.1",
    "re…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by stevenvachon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant