-
-
Notifications
You must be signed in to change notification settings - Fork 5
Add starter-mastro #101
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
Merged
Merged
Add starter-mastro #101
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "recommendations": ["ms-fast.fast-tagged-templates"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # Mastro Template Basic for Node.js | ||
|
|
||
| This is a basic TypeScript template for [Mastro](https://mastrojs.github.io) when using [Node.js](https://nodejs.org). | ||
|
|
||
| Click the green **Use this template** button in the top right to create your own copy of this repository. Then clone the **Code** to your computer. | ||
|
|
||
| ## Run locally | ||
|
|
||
| If you have multiple projects on your computer that require different Node.js versions, you should install a tool to manage those version for you; for example [Volta](https://volta.sh/) (see [pnpm Support](https://docs.volta.sh/advanced/pnpm)). | ||
|
|
||
| Mastro requires Node.js >=24 (unless you want to install a [`URLPattern` polyfill](https://www.npmjs.com/package/urlpattern-polyfill)). | ||
|
|
||
| [JSR recommends](https://jsr.io/docs/npm-compatibility#installing-and-using-jsr-packages) to use `pnpm`. | ||
|
|
||
| The first time, you need to: | ||
|
|
||
| pnpm install | ||
|
|
||
| After that, to start the server: | ||
|
|
||
| pnpm run start | ||
|
|
||
| and open <http://localhost:8000> in your browser. | ||
|
|
||
| To generate the whole static site (this will create a `generated` folder): | ||
|
|
||
| pnpm run generate | ||
|
|
||
| ## Next steps | ||
|
|
||
| To see how Mastro works, [follow the guide](https://mastrojs.github.io/guide/server-side-components-and-routing/). | ||
|
|
||
| To make sure you're using the latest Mastro packages: | ||
|
|
||
| pnpm update "@mastrojs/*" --latest | ||
|
|
||
| ## Deploy to production | ||
|
|
||
| - [Deploy static site](https://mastrojs.github.io/guide/deploy/#deploy-static-site-with-ci%2Fcd) | ||
| - [Deploy server](https://mastrojs.github.io/guide/deploy/#deploy-server-to-production) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { type Html, html } from '@mastrojs/mastro' | ||
|
|
||
| interface Props { | ||
| children: Html | ||
| title: string | ||
| } | ||
|
|
||
| export const Layout = (props: Props) => html` | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <title>${props.title}</title> | ||
| <link rel="stylesheet" href="/styles.css" /> | ||
| </head> | ||
| <body> | ||
| <h1>${props.title}</h1> | ||
| ${props.children} | ||
| </body> | ||
| </html> | ||
| ` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "name": "starter-mastro", | ||
| "type": "module", | ||
| "scripts": { | ||
| "dev": "node --watch server.ts", | ||
| "build": "node node_modules/@mastrojs/mastro/src/generator.js", | ||
| "check": "tsc" | ||
| }, | ||
| "dependencies": { | ||
| "@mastrojs/mastro": "jsr:^0", | ||
| "@remix-run/node-fetch-server": "^0.11" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/node": "^24", | ||
| "typescript": "^5" | ||
| }, | ||
| "engines": { | ||
| "node": ">=24.12" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { html, htmlToResponse } from '@mastrojs/mastro' | ||
| import { Layout } from '../components/Layout.ts' | ||
|
|
||
| export const GET = (_req: Request) => | ||
| htmlToResponse( | ||
| Layout({ | ||
| title: 'Hello World', | ||
| children: html` <p>Welcome!</p> `, | ||
| }), | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| html { | ||
| font-family: sans-serif; | ||
| } | ||
|
|
||
| h1, | ||
| h2, | ||
| h3, | ||
| h4, | ||
| h5, | ||
| h6 { | ||
| word-break: break-word; | ||
| text-wrap-style: pretty; | ||
| } | ||
|
|
||
| p { | ||
| hyphens: auto; | ||
| word-break: break-word; | ||
| } | ||
|
|
||
| img { | ||
| max-width: 100%; | ||
| } | ||
|
|
||
| @view-transition { | ||
| navigation: auto; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import * as http from 'node:http' | ||
| import { createRequestListener } from '@remix-run/node-fetch-server' | ||
| import mastro from '@mastrojs/mastro/server' | ||
|
|
||
| const port = 8000 | ||
|
|
||
| const server = http.createServer(createRequestListener(mastro.fetch)) | ||
|
|
||
| server.on('error', (e) => { | ||
| console.error(e) | ||
| }) | ||
|
|
||
| server.listen(port, () => { | ||
| console.log(`Server running at http://localhost:${port}`) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "allowImportingTsExtensions": true, | ||
| "module": "NodeNext", | ||
| "moduleResolution": "nodenext", | ||
| "noEmit": true, | ||
| "skipLibCheck": true, | ||
| "strict": true, | ||
| "verbatimModuleSyntax": true, | ||
|
|
||
| "noFallthroughCasesInSwitch": true, | ||
| "noUncheckedIndexedAccess": true, | ||
| "noImplicitOverride": true | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.