Compare commits
131 Commits
feat/engin
...
@rocket/cl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8082fbac8 | ||
|
|
68e05f4d4a | ||
|
|
660f64c320 | ||
|
|
97d5fb2040 | ||
|
|
0ca2bc6205 | ||
|
|
e53e0ebd6d | ||
|
|
87c10ec1d3 | ||
|
|
d7e461ca31 | ||
|
|
a12adf2cb5 | ||
|
|
acf84416dc | ||
|
|
a48dcd849b | ||
|
|
0ed3d6d0e9 | ||
|
|
57ec19fecc | ||
|
|
8b48fb9760 | ||
|
|
39206a1738 | ||
|
|
cbfb0f91e2 | ||
|
|
58692147e9 | ||
|
|
8dedc56afa | ||
|
|
bcbfae332d | ||
|
|
0fae0037d8 | ||
|
|
390335da18 | ||
|
|
6d2f469d26 | ||
|
|
94a6f54585 | ||
|
|
ff8b4c5cd5 | ||
|
|
5122ea8639 | ||
|
|
3032ba9b82 | ||
|
|
93503ed309 | ||
|
|
77646abbee | ||
|
|
9ae3966fef | ||
|
|
09a47b43dc | ||
|
|
42d794bdfc | ||
|
|
b8a1b45953 | ||
|
|
379f08ff47 | ||
|
|
50bb68ab7f | ||
|
|
250ca87a9d | ||
|
|
6f88d8ef6f | ||
|
|
35ed64dca1 | ||
|
|
2555a8698d | ||
|
|
367529c211 | ||
|
|
ce3298d218 | ||
|
|
a22da493dd | ||
|
|
7a8f165625 | ||
|
|
c8081071f7 | ||
|
|
ab2436162c | ||
|
|
b563967319 | ||
|
|
c84d51207f | ||
|
|
5226ab0150 | ||
|
|
f9c8a20d19 | ||
|
|
e02da22db0 | ||
|
|
b50be310c0 | ||
|
|
6b33e20c73 | ||
|
|
93a3089c7e | ||
|
|
b0630b5bfc | ||
|
|
545cd493da | ||
|
|
6c949ee80d | ||
|
|
09cca4c486 | ||
|
|
dbeafbb7f6 | ||
|
|
445daf67e3 | ||
|
|
f06ea2117b | ||
|
|
252e4ea60e | ||
|
|
22be8d52a0 | ||
|
|
aeb5ad2e99 | ||
|
|
2bc4282efa | ||
|
|
873e6f325d | ||
|
|
d879480c0c | ||
|
|
f2bc47bb40 | ||
|
|
59fa80119f | ||
|
|
8c76c2d9d5 | ||
|
|
a74b8b370a | ||
|
|
bbe83b9923 | ||
|
|
409bb2f1e4 | ||
|
|
0f77a8b9d7 | ||
|
|
0226d08de6 | ||
|
|
cb49251158 | ||
|
|
d33400e12e | ||
|
|
b3194556c2 | ||
|
|
7732541df4 | ||
|
|
72ed8d274a | ||
|
|
f4d83fe958 | ||
|
|
af55e855c8 | ||
|
|
0f6a42edaa | ||
|
|
43df19f4a7 | ||
|
|
894a2fe56d | ||
|
|
0cb5ca7153 | ||
|
|
d220d35609 | ||
|
|
2d9eec2b15 | ||
|
|
1089007ba2 | ||
|
|
19f31854f9 | ||
|
|
cb105c5f1e | ||
|
|
1968e2365d | ||
|
|
d2a6698587 | ||
|
|
5fe1e47687 | ||
|
|
3eea6e2bf9 | ||
|
|
bf8764583d | ||
|
|
4ac62106a2 | ||
|
|
c2c9ecd39a | ||
|
|
1d75d0b62f | ||
|
|
607b94bf4d | ||
|
|
927566f2a5 | ||
|
|
0c696f544a | ||
|
|
ec81c40dce | ||
|
|
825e331ef5 | ||
|
|
f63c20d440 | ||
|
|
fcf98bf984 | ||
|
|
1941eddc8d | ||
|
|
5c802cc4d3 | ||
|
|
81f989a1c6 | ||
|
|
4b1919c02d | ||
|
|
55c8b3fcc3 | ||
|
|
e1a1cf6cf9 | ||
|
|
9536efc46a | ||
|
|
a73e2dfe19 | ||
|
|
4d0da40087 | ||
|
|
b00d17b491 | ||
|
|
130a544d43 | ||
|
|
528f6da180 | ||
|
|
fa41908d0e | ||
|
|
e17671c448 | ||
|
|
c009801164 | ||
|
|
60310ab3dd | ||
|
|
db03f69210 | ||
|
|
e6c3d274cf | ||
|
|
f9014c15a6 | ||
|
|
7e277cd88f | ||
|
|
bc6106381c | ||
|
|
00bf3882f6 | ||
|
|
543e297c5b | ||
|
|
70b0ce8e1c | ||
|
|
9f8785a885 | ||
|
|
62637a829e | ||
|
|
81c4d7bf3c |
@@ -1,4 +0,0 @@
|
|||||||
node_modules/**
|
|
||||||
/docs/_assets
|
|
||||||
/docs/_includes
|
|
||||||
/docs/_data
|
|
||||||
@@ -12,3 +12,14 @@ __output
|
|||||||
__output-dev
|
__output-dev
|
||||||
|
|
||||||
docs/_merged*
|
docs/_merged*
|
||||||
|
*-mdjs-generated.js
|
||||||
|
|
||||||
|
# sanity example has a separate backend that is unrelated to Rocket
|
||||||
|
# therefore it does not need to follow it code rules
|
||||||
|
/examples/04-sanity-minimal-starter/backend/
|
||||||
|
|
||||||
|
/packages/engine/test-node/fixtures/06-error-handling/01-page-error/docs/index.rocket.js
|
||||||
|
/packages/engine/test-node/fixtures/03b-format-markdown/c01-md-in-js-to-md-html/md-in-js.js
|
||||||
|
/packages/engine/test-node/fixtures/03b-format-markdown/04-keep-converted-files/index-converted-md.js
|
||||||
|
/packages/engine/test-node/fixtures/03c-format-html/02-client-js/docs/index-converted-html.js
|
||||||
|
/packages/engine/test-node/fixtures/03b-format-markdown/04-keep-converted-files/index-converted-md-source.js
|
||||||
|
|||||||
8
.github/workflows/verify.yml
vendored
@@ -8,7 +8,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [14.x]
|
node-version: [16.x]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
@@ -32,7 +32,11 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn --frozen-lockfile
|
run: yarn --frozen-lockfile
|
||||||
|
|
||||||
- uses: microsoft/playwright-github-action@v1
|
- name: Install Playwright dependencies
|
||||||
|
run: npx playwright install-deps
|
||||||
|
|
||||||
|
- name: Install Playwright
|
||||||
|
run: npx playwright install
|
||||||
|
|
||||||
- name: Build Packages
|
- name: Build Packages
|
||||||
run: yarn build:packages
|
run: yarn build:packages
|
||||||
|
|||||||
13
.gitignore
vendored
@@ -1,5 +1,7 @@
|
|||||||
## editors
|
## editors
|
||||||
/.idea
|
/.idea
|
||||||
|
/.vscode
|
||||||
|
/.history
|
||||||
|
|
||||||
## system files
|
## system files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
@@ -26,8 +28,14 @@ dist-types
|
|||||||
stats.html
|
stats.html
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
|
|
||||||
## Rocket ignore files (need to be the full relative path to the folders)
|
# Rocket Search
|
||||||
|
rocket-search-index.json
|
||||||
|
|
||||||
|
## Rocket ignore files
|
||||||
*-mdjs-generated.js
|
*-mdjs-generated.js
|
||||||
|
*-converted-md-source.js
|
||||||
|
*-converted-md.js
|
||||||
|
*-converted-html.js
|
||||||
_site
|
_site
|
||||||
_site-dev
|
_site-dev
|
||||||
|
|
||||||
@@ -38,3 +46,6 @@ _merged_includes
|
|||||||
__output
|
__output
|
||||||
__output-dev
|
__output-dev
|
||||||
docs_backup
|
docs_backup
|
||||||
|
|
||||||
|
## Local playground
|
||||||
|
examples/testing
|
||||||
|
|||||||
6
.vscode/settings.json
vendored
@@ -2,9 +2,11 @@
|
|||||||
"gitdoc.enabled": false,
|
"gitdoc.enabled": false,
|
||||||
"typescript.tsdk": "node_modules/typescript/lib",
|
"typescript.tsdk": "node_modules/typescript/lib",
|
||||||
"files.exclude": {
|
"files.exclude": {
|
||||||
"**/*-mdjs-generated.js": true,
|
"**/*-mdjs-generated.js": false,
|
||||||
},
|
},
|
||||||
"search.exclude": {
|
"search.exclude": {
|
||||||
"**/*-mdjs-generated.js": true,
|
"**/*-mdjs-generated.js": true,
|
||||||
}
|
"**/dist-types": true,
|
||||||
|
},
|
||||||
|
"editor.experimental.stickyScroll.enabled": true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,25 +8,25 @@ First, create a fork of the [modernweb-dev/rocket](https://github.com/modernweb-
|
|||||||
|
|
||||||
Next, clone our repository onto your computer.
|
Next, clone our repository onto your computer.
|
||||||
|
|
||||||
```sh
|
```shell
|
||||||
git clone git@github.com:modernweb-dev/rocket.git
|
git clone git@github.com:modernweb-dev/rocket.git
|
||||||
```
|
```
|
||||||
|
|
||||||
Once cloning is complete, change directory to the repository.
|
Once cloning is complete, change directory to the repository.
|
||||||
|
|
||||||
```sh
|
```shell
|
||||||
cd rocket
|
cd rocket
|
||||||
```
|
```
|
||||||
|
|
||||||
Now add your fork as a remote (replacing YOUR_USERNAME with your GitHub username).
|
Now add your fork as a remote (replacing YOUR_USERNAME with your GitHub username).
|
||||||
|
|
||||||
```sh
|
```shell
|
||||||
git remote add fork git@github.com:<YOUR_USERNAME>/rocket.git
|
git remote add fork git@github.com:<YOUR_USERNAME>/rocket.git
|
||||||
```
|
```
|
||||||
|
|
||||||
Create a new local branch.
|
Create a new local branch.
|
||||||
|
|
||||||
```sh
|
```shell
|
||||||
git checkout -b my-awesome-fix
|
git checkout -b my-awesome-fix
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ git checkout -b my-awesome-fix
|
|||||||
|
|
||||||
Now that you have cloned the repository, ensure you have [yarn](https://classic.yarnpkg.com/lang/en/) installed, then run the following commands to set up the development environment.
|
Now that you have cloned the repository, ensure you have [yarn](https://classic.yarnpkg.com/lang/en/) installed, then run the following commands to set up the development environment.
|
||||||
|
|
||||||
```sh
|
```shell
|
||||||
yarn install
|
yarn install
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ This documents your intent to release, and allows you to specify a message that
|
|||||||
|
|
||||||
Run
|
Run
|
||||||
|
|
||||||
```sh
|
```shell
|
||||||
yarn changeset
|
yarn changeset
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ Exceptions:
|
|||||||
Commit messages must follow the [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0/)
|
Commit messages must follow the [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0/)
|
||||||
Modern-web uses package name as scope. So for example if you fix a _terrible bug_ in the package `@web/test-runner`, the commit message should look like this:
|
Modern-web uses package name as scope. So for example if you fix a _terrible bug_ in the package `@web/test-runner`, the commit message should look like this:
|
||||||
|
|
||||||
```sh
|
```shell
|
||||||
fix(test-runner): fix terrible bug
|
fix(test-runner): fix terrible bug
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ fix(test-runner): fix terrible bug
|
|||||||
|
|
||||||
Now it's time to push your branch that contains your committed changes to your fork.
|
Now it's time to push your branch that contains your committed changes to your fork.
|
||||||
|
|
||||||
```sh
|
```shell
|
||||||
git push -u fork my-awesome-fix
|
git push -u fork my-awesome-fix
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
29
README.md
@@ -1,11 +1,10 @@
|
|||||||
> This project is in its BETA phase
|
> This project is in its BETA phase
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img
|
<picture width="60%">
|
||||||
width="60%"
|
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/modernweb-dev/rocket/main/site/src/assets/rocket-logo-dark-with-text.svg">
|
||||||
src="./assets/logo.png"
|
<img alt="Rocket Logo" src="https://raw.githubusercontent.com/modernweb-dev/rocket/main/site/src/assets/rocket-logo-light-with-text.svg">
|
||||||
alt="Rocket"
|
</picture>
|
||||||
/>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
@@ -21,7 +20,7 @@
|
|||||||
/></a>
|
/></a>
|
||||||
<a href="https://open.vscode.dev/modernweb-dev/rocket"
|
<a href="https://open.vscode.dev/modernweb-dev/rocket"
|
||||||
><img
|
><img
|
||||||
src="https://open.vscode.dev/badges/open-in-vscode.svg"
|
src="https://img.shields.io/static/v1?logo=visualstudiocode&label=&message=Open%20in%20Visual%20Studio%20Code&labelColor=2c2c32&color=007acc&logoColor=007acc"
|
||||||
alt="Open in VS Code"
|
alt="Open in VS Code"
|
||||||
/></a>
|
/></a>
|
||||||
</p>
|
</p>
|
||||||
@@ -29,9 +28,9 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://rocket.modern-web.dev">Website</a>
|
<a href="https://rocket.modern-web.dev">Website</a>
|
||||||
·
|
·
|
||||||
<a href="https://rocket.modern-web.dev/guides/">Guides</a>
|
|
||||||
·
|
|
||||||
<a href="https://rocket.modern-web.dev/docs/">Documentation</a>
|
<a href="https://rocket.modern-web.dev/docs/">Documentation</a>
|
||||||
|
·
|
||||||
|
<a href="https://rocket.modern-web.dev/chat">Discord Community</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h1></h1>
|
<h1></h1>
|
||||||
@@ -43,7 +42,7 @@
|
|||||||
- **Small:** No overblown tools or frontend frameworks, add JavaScript and/or Web Components only on pages where needed..
|
- **Small:** No overblown tools or frontend frameworks, add JavaScript and/or Web Components only on pages where needed..
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://rocket.modern-web.dev/guides/"><strong>Explore the Rocket Guides ▶</strong></a>
|
<a href="https://rocket.modern-web.dev/docs/setup/getting-started/"><strong>Getting Started With Rocket ▶</strong></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## The Goal for Rocket
|
## The Goal for Rocket
|
||||||
@@ -55,21 +54,21 @@ You can still tweak every detail of every underlying tool that gets used.
|
|||||||
|
|
||||||
Rocket is part of the [Modern Web Family](https://twitter.com/modern_web_dev).
|
Rocket is part of the [Modern Web Family](https://twitter.com/modern_web_dev).
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://rocket.modern-web.dev/chat"><strong>Join our Discord Community ▶</strong></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
```
|
```
|
||||||
mkdir test-rocket
|
npx @rocket/create@latest
|
||||||
cd test-rocket
|
|
||||||
npm init -y
|
|
||||||
npm i @rocket/cli@alpha @rocket/launch@alpha @11ty/eleventy-cache-assets typescript
|
|
||||||
npx rocket init
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🤝 Contributing
|
## 🤝 Contributing
|
||||||
|
|
||||||
We are always looking for contributors of all skill levels! If you're looking to ease your way into the project, try out a [good first issue](https://github.com/modernweb-dev/rocket/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22).
|
We are always looking for contributors of all skill levels! If you're looking to ease your way into the project, try out a [good first issue](https://github.com/modernweb-dev/rocket/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22).
|
||||||
|
|
||||||
If you are interested in helping contribute to Modern Web, please take a look at our [Contributing Guide](https://github.com/modernweb-dev/rocket/blob/main/CONTRIBUTING.md). Also, feel free to drop into [slack](https://rocket.modern-web.dev/about/slack/) and say hi. 👋
|
If you are interested in helping contribute to Modern Web, please take a look at our [Contributing Guide](https://github.com/modernweb-dev/rocket/blob/main/CONTRIBUTING.md). Also, feel free to drop into [discord](https://rocket.modern-web.dev/chat) and say hi. 👋
|
||||||
|
|
||||||
### Financial Contributors
|
### Financial Contributors
|
||||||
|
|
||||||
|
|||||||
22
TODO.md
@@ -1,31 +1,32 @@
|
|||||||
|
## TODO
|
||||||
|
|
||||||
|
- 404 page background images are not being loaded
|
||||||
|
- sitemap.xml not deployed on netlify
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Rename "options.docsDir" to "options.inputDir"
|
|
||||||
- recursive rendering of lit / html / and markdown
|
- recursive rendering of lit / html / and markdown
|
||||||
- convert `<meta name="menu:link.text" content="Docs" />` to `export const menuLinkText = 'Docs';`
|
- "import" markdown with frontmatter
|
||||||
- "import" markdown with frontmatter
|
- mdjs update to unified v10 AND go esm only (only cjs pkg we have now)
|
||||||
- export const mdCleanup = false; => to not clean up auto generated md files for this page
|
|
||||||
- add helper for layouts
|
## Nice to have
|
||||||
|
|
||||||
- Add "menuExclude" => to actually exclude the menu item
|
- Add "menuExclude" => to actually exclude the menu item
|
||||||
|
|
||||||
## Bugs
|
## Bugs
|
||||||
|
|
||||||
- write to `_site-dev` instead of `_site` while using `rocket start`
|
- write to `_site-dev` instead of `_site` while using `rocket start`
|
||||||
- nested `recursive.data.js` do not overwrite the parent data
|
- nested `recursive.data.js` do not overwrite the parent data
|
||||||
- rocketGeneratedMdInJs => converted-md-source
|
|
||||||
- rocketGeneratedFromMd => converted-md
|
|
||||||
- support <!-- asdf --> in markdown
|
- support <!-- asdf --> in markdown
|
||||||
- ssr render can just be a string concat
|
|
||||||
|
|
||||||
## Error Handling
|
## Error Handling
|
||||||
|
|
||||||
- make error nice for "needs function export default () => html` instead of just export default html`"
|
|
||||||
- make error nice for parent page not found in index => auto generate page? 🤔
|
- make error nice for parent page not found in index => auto generate page? 🤔
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
- docs site, blog (simple), blog (complex), minimal
|
- docs site, blog (simple), blog (complex), minimal
|
||||||
- add stackblitz/codesandbox examples
|
- add stackblitz/codesandbox examples => does not work because of `@parcel/watcher` https://github.com/parcel-bundler/watcher/issues/99
|
||||||
|
|
||||||
- Example: export variable and use it in rendering
|
- Example: export variable and use it in rendering
|
||||||
- Example: fetch data from an api and display it
|
- Example: fetch data from an api and display it
|
||||||
@@ -35,6 +36,7 @@
|
|||||||
|
|
||||||
- support `@change` in markdown
|
- support `@change` in markdown
|
||||||
- support "hey ${foo.map(f => `${f} + 1`)}"
|
- support "hey ${foo.map(f => `${f} + 1`)}"
|
||||||
|
- ENGINE: Rename "options.docsDir" to "options.inputDir"
|
||||||
|
|
||||||
## consider
|
## consider
|
||||||
|
|
||||||
|
|||||||
BIN
assets/logo.png
|
Before Width: | Height: | Size: 10 KiB |
47
config/rocket.config.js
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import { rocketLaunch } from '@rocket/launch';
|
||||||
|
import { rocketSpark } from '@rocket/spark';
|
||||||
|
import { presetRocketSearch } from '@rocket/search';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the current applicable absoluteBaseUrl from Netlify system variables
|
||||||
|
*
|
||||||
|
* @param {string} fallback
|
||||||
|
*/
|
||||||
|
export function absoluteBaseUrlNetlify(fallback) {
|
||||||
|
let absoluteBaseUrl = fallback;
|
||||||
|
|
||||||
|
switch (process.env.CONTEXT) {
|
||||||
|
case 'production':
|
||||||
|
absoluteBaseUrl = process.env.URL ?? '';
|
||||||
|
break;
|
||||||
|
case 'deploy-preview':
|
||||||
|
absoluteBaseUrl = process.env.DEPLOY_URL ?? '';
|
||||||
|
break;
|
||||||
|
case 'branch-deploy':
|
||||||
|
absoluteBaseUrl = process.env.DEPLOY_PRIME_URL ?? '';
|
||||||
|
break;
|
||||||
|
/* no default */
|
||||||
|
}
|
||||||
|
return absoluteBaseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default /** @type {import('@rocket/cli/types/main').RocketCliOptions} */ ({
|
||||||
|
absoluteBaseUrl: absoluteBaseUrlNetlify('http://localhost:8080'),
|
||||||
|
longFileHeaderWidth: 100,
|
||||||
|
longFileHeaderComment: '// prettier-ignore',
|
||||||
|
// adjustDevServerOptions: (options) => ({
|
||||||
|
// ...options,
|
||||||
|
// nodeResolve: {
|
||||||
|
// ...options.nodeResolve,
|
||||||
|
// exportConditions: ['development'],
|
||||||
|
// },
|
||||||
|
// }),
|
||||||
|
|
||||||
|
// buildOpenGraphImages: false,
|
||||||
|
|
||||||
|
presets: [rocketLaunch(), rocketSpark(), presetRocketSearch()],
|
||||||
|
// serviceWorkerName: 'sw.js',
|
||||||
|
// pathPrefix: '/_site/',
|
||||||
|
|
||||||
|
// clearOutputDir: false,
|
||||||
|
});
|
||||||
@@ -1,177 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '10--guides/10--first-pages/10--getting-started.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
# Getting Started
|
|
||||||
|
|
||||||
Rocket has the following prerequisites:
|
|
||||||
|
|
||||||
- [Node 14+](https://nodejs.org/en/)
|
|
||||||
|
|
||||||
Make sure they are installed before proceeding.
|
|
||||||
|
|
||||||
## Setup
|
|
||||||
|
|
||||||
The fastest way to get started is by using an existing preset like the launch preset.
|
|
||||||
|
|
||||||
### Step 1. Initialize the Project Package
|
|
||||||
|
|
||||||
Start by creating an empty folder for your project
|
|
||||||
|
|
||||||
```bash copy
|
|
||||||
mkdir my-project
|
|
||||||
cd my-project
|
|
||||||
```
|
|
||||||
|
|
||||||
Then initialize a package.json file
|
|
||||||
|
|
||||||
<code-tabs collection="package-managers" default-tab="npm" align="end">
|
|
||||||
|
|
||||||
```bash tab npm
|
|
||||||
npm init -y
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash tab yarn
|
|
||||||
yarn init -y
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash tab pnpm
|
|
||||||
pnpm init -y
|
|
||||||
```
|
|
||||||
|
|
||||||
</code-tabs>
|
|
||||||
|
|
||||||
### Step 2. Install dependencies
|
|
||||||
|
|
||||||
<code-tabs collection="package-managers" default-tab="npm" align="end">
|
|
||||||
|
|
||||||
```bash tab npm
|
|
||||||
npm install --save-dev @rocket/cli @rocket/launch
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash tab yarn
|
|
||||||
yarn add -D @rocket/cli @rocket/launch
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash tab pnpm
|
|
||||||
pnpm add -D @rocket/cli @rocket/launch
|
|
||||||
```
|
|
||||||
|
|
||||||
</code-tabs>
|
|
||||||
|
|
||||||
### Step 3. Bootstrap the project
|
|
||||||
|
|
||||||
<code-tabs collection="package-managers" default-tab="npm" align="end">
|
|
||||||
|
|
||||||
```bash tab npm
|
|
||||||
npx rocket bootstrap
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash tab yarn
|
|
||||||
yarn rocket bootstrap
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash tab pnpm
|
|
||||||
pnpx rocket bootstrap
|
|
||||||
```
|
|
||||||
|
|
||||||
</code-tabs>
|
|
||||||
|
|
||||||
The `bootstrap` command creates four files in your repo:
|
|
||||||
|
|
||||||
- `rocket.config.js` containing a minimal rocket config
|
|
||||||
- `docs/index.md` your first page
|
|
||||||
- `.gitignore` containing rocket's build artifacts
|
|
||||||
- `.vscode/settings.json` hide build artifacts in your vscode
|
|
||||||
|
|
||||||
It also set the package `type` to `"module"` and adds a `start` and `docs` package scripts.
|
|
||||||
|
|
||||||
<inline-notification type="warning">
|
|
||||||
|
|
||||||
If you don't want to use the `module` package type, make sure to rename the generated config file to `rocket.config.mjs`.
|
|
||||||
|
|
||||||
</inline-notification>
|
|
||||||
|
|
||||||
<details><summary>Default Files Contents</summary>
|
|
||||||
|
|
||||||
<code-tabs default-tab="rocket.config.js">
|
|
||||||
|
|
||||||
```js tab rocket.config.js
|
|
||||||
import { rocketLaunch } from '@rocket/launch';
|
|
||||||
|
|
||||||
/** @type {import('rocket/cli').RocketCliConfig} */
|
|
||||||
export default {
|
|
||||||
presets: [rocketLaunch()],
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
```md tab docs/index.md
|
|
||||||
# Welcome to Your Rocket Site
|
|
||||||
|
|
||||||
Add your markdown content here.
|
|
||||||
```
|
|
||||||
|
|
||||||
```html tab .gitignore
|
|
||||||
## Rocket ignore files (need to be the full relative path to the folders) docs/_merged_data/
|
|
||||||
docs/_merged_assets/ docs/_merged_includes/
|
|
||||||
```
|
|
||||||
|
|
||||||
</code-tabs>
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
## Add your First Page
|
|
||||||
|
|
||||||
Bootstrap created the file `docs/index.md`. Open it in your editor and change it to suit your needs.
|
|
||||||
|
|
||||||
<small>NOTE: This tutorial assumes you are familiar with Markdown, for page authoring.</small>
|
|
||||||
|
|
||||||
```md
|
|
||||||
# Welcome to Your Rocket Site
|
|
||||||
|
|
||||||
Add your markdown content here.
|
|
||||||
```
|
|
||||||
|
|
||||||
Please note that the heading - text prefixed with `#` or `##` - is not optional for each page in this tutorial. Everything below that first line is optional Markdown text.
|
|
||||||
|
|
||||||
## Startup
|
|
||||||
|
|
||||||
Now you can launch your site locally with
|
|
||||||
|
|
||||||
<code-tabs collection="package-managers" default-tab="npm" align="end">
|
|
||||||
|
|
||||||
```bash tab npm
|
|
||||||
npm start
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash tab yarn
|
|
||||||
yarn start
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash tab pnpm
|
|
||||||
pnpx start
|
|
||||||
```
|
|
||||||
|
|
||||||
</code-tabs>
|
|
||||||
|
|
||||||
## Taking Inventory Before Adding Pages:
|
|
||||||
|
|
||||||
We're about to add both content and navigation at the same time.
|
|
||||||
|
|
||||||
It can be helpful to take an inventory, before we start, to separate basic setup from the creation of content and navigation.
|
|
||||||
|
|
||||||
- We built the project with basic npm commands
|
|
||||||
- Added a couple required files manually
|
|
||||||
- Adjusted package.json
|
|
||||||
- **docs/index.md** to seed the content
|
|
||||||
- Launches with `npm start`
|
|
||||||
|
|
||||||
That's all it takes to get a new super-fast and powerful site, complete with a service worker, default styling, navigation, and ready to deploy as a plain old static files.
|
|
||||||
|
|
||||||
```js script
|
|
||||||
import '@rocket/launch/inline-notification/inline-notification.js';
|
|
||||||
```
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '10--guides/10--first-pages/20--adding-pages.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
# Adding Pages
|
|
||||||
|
|
||||||
<inline-notification type="warning">
|
|
||||||
|
|
||||||
You can do this whole part of the tutorial in a couple minutes. It's almost _**too**_ fast.
|
|
||||||
|
|
||||||
It can help to examine each new page and menu carefully, to come to terms with the implicit navigation created by your addition of new content, at least the first couple of times.
|
|
||||||
|
|
||||||
</inline-notification>
|
|
||||||
|
|
||||||
## Add a Section
|
|
||||||
|
|
||||||
In most cases you will have multiple sections in your website and each of those sections will come with its own sidebar navigation.
|
|
||||||
|
|
||||||
To create a section you need to create a folder with an `index.rocket.md`.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
mkdir docs/guides
|
|
||||||
```
|
|
||||||
|
|
||||||
👉 `docs/guides/index.rocket.md`
|
|
||||||
|
|
||||||
```md
|
|
||||||
# Guides
|
|
||||||
|
|
||||||
You can read all about...
|
|
||||||
```
|
|
||||||
|
|
||||||
Observe that this creates a section named "Guides" at the top menu bar, and a page with the same title.
|
|
||||||
|
|
||||||
<inline-notification type="tip">
|
|
||||||
|
|
||||||
Don't worry if this isn't how you would have styled or placed your menu bar or sidebar navigation, we'll get to customization of the default preset later in the tutorials.
|
|
||||||
|
|
||||||
</inline-notification>
|
|
||||||
|
|
||||||
> How many sections should I add?
|
|
||||||
|
|
||||||
It might be more practical to stay below 5 sections.
|
|
||||||
|
|
||||||
## Adding a Category
|
|
||||||
|
|
||||||
Often each section will have multiple categories.
|
|
||||||
|
|
||||||
To create a category you need to create a folder with an `index.rocket.md`.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
mkdir docs/guides/first-pages/
|
|
||||||
```
|
|
||||||
|
|
||||||
👉 `docs/guides/first-pages/index.rocket.md`
|
|
||||||
|
|
||||||
```md
|
|
||||||
# First Pages
|
|
||||||
```
|
|
||||||
|
|
||||||
## Adding a Page to a Category
|
|
||||||
|
|
||||||
👉 `docs/guides/first-pages/getting-started.rocket.md`
|
|
||||||
|
|
||||||
```md
|
|
||||||
# Getting Started
|
|
||||||
|
|
||||||
This is how you get started.
|
|
||||||
```
|
|
||||||
|
|
||||||
## Headings as Anchor and Menu Items
|
|
||||||
|
|
||||||
_**Within**_ any page, you can still add links to your navigation!
|
|
||||||
|
|
||||||
Note that Markdown text prefixed with one or two # signs also becomes an anchor in the page and a link in the sidebar navigation when the page is open.
|
|
||||||
|
|
||||||
```md
|
|
||||||
## Headings as Anchor and Menu Items
|
|
||||||
|
|
||||||
_**Within**_ any page, you can still add links to your navigation!
|
|
||||||
```
|
|
||||||
|
|
||||||
```js script
|
|
||||||
import '@rocket/launch/inline-notification/inline-notification.js';
|
|
||||||
```
|
|
||||||
|
|
||||||
## Example as a Reference
|
|
||||||
|
|
||||||
If implicit navigation, derived from content, is a bit too much to grasp in one sitting, feel free to examine the **docs** folder in [the rocket codebase behind the pages you are reading](https://github.com/modernweb-dev/rocket) for more examples.
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '10--guides/10--first-pages/30--use-javascript.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
# Use JavaScript
|
|
||||||
|
|
||||||
If you would like to add JavaScript to a page, you can do it inline using the `script` markdown directive. The script you write runs on the page as a module.
|
|
||||||
|
|
||||||
````markdown
|
|
||||||
```js script
|
|
||||||
const message = 'Hello, World!';
|
|
||||||
console.log(message);
|
|
||||||
```
|
|
||||||
````
|
|
||||||
|
|
||||||
Adding the above will log `Hello, World!` to the console without adding a global `message` variable.
|
|
||||||
|
|
||||||
This can be useful for importing web components and using them in Markdown. Imagine you had some `magic-reveal` element that you wanted to use on a page:
|
|
||||||
|
|
||||||
````markdown
|
|
||||||
```js script
|
|
||||||
import 'magic-reveal/magic-reveal.js';
|
|
||||||
```
|
|
||||||
|
|
||||||
<magic-reveal>
|
|
||||||
|
|
||||||
This text will get magically revealed.
|
|
||||||
|
|
||||||
I can **still** use Markdown as long as there is an empty line
|
|
||||||
between the opening/closing tags and my text.
|
|
||||||
|
|
||||||
</magic-reveal>
|
|
||||||
````
|
|
||||||
|
|
||||||
## Component Story Format
|
|
||||||
|
|
||||||
You can also add storybook-style CSF (v2 only) stories to a page using `js story` or `js preview-story`, just make sure to import `html` from `@mdjs/mdjs-preview` instead of from `lit` or `lit-html`.
|
|
||||||
|
|
||||||
````markdown
|
|
||||||
```js story
|
|
||||||
import { html } from '@mdjs/mdjs-preview';
|
|
||||||
|
|
||||||
export const StoryPreview = () => html` <p>Use stories in Rocket!</p> `;
|
|
||||||
```
|
|
||||||
````
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '10--guides/10--first-pages/index.rocket.js';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
|
|
||||||
import { html } from 'lit-html';
|
|
||||||
export default () => html`<h1>First Pages</h1>
|
|
||||||
<meta name="menu:exclude" content="true" />`;
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '10--guides/20--presets/10--getting-started.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
# Getting Started
|
|
||||||
|
|
||||||
Presets are partial rocket configs that combine any number of plugins to add specific features. Rocket is built on these presets, like `rocketLaunch`, `rocketBlog`, and `rocketSearch`
|
|
||||||
|
|
||||||
You can use a preset via the config by adding it to the `presets` array
|
|
||||||
|
|
||||||
<!-- prettier-ignore-start -->
|
|
||||||
```js copy
|
|
||||||
import { rocketLaunch } from '@rocket/launch';
|
|
||||||
import { rocketBlog } from '@rocket/blog';
|
|
||||||
import { rocketSearch } from '@rocket/search';
|
|
||||||
|
|
||||||
/** @type {import('@rocket/cli').RocketCliOptions} */
|
|
||||||
export default ({
|
|
||||||
presets: [rocketLaunch(), rocketBlog(), rocketSearch()],
|
|
||||||
});
|
|
||||||
```
|
|
||||||
<!-- prettier-ignore-end -->
|
|
||||||
|
|
||||||
## Community Presets
|
|
||||||
|
|
||||||
There are a number of community-made presets available:
|
|
||||||
|
|
||||||
<!--
|
|
||||||
-- Thank you for your interest in rocket. To add your preset,
|
|
||||||
-- follow the format below. Please add your preset in alphabetical order.
|
|
||||||
-->
|
|
||||||
|
|
||||||
- [rocket-preset-code-tabs](https://www.npmjs.com/package/rocket-preset-code-tabs) - Add tab elements for code blocks
|
|
||||||
- [rocket-preset-custom-elements-manifest](https://www.npmjs.com/package/rocket-preset-custom-elements-manifest) - Documents code generation for JavaScript libraries, particularly custom elements.
|
|
||||||
- [rocket-preset-markdown-directive](https://www.npmjs.com/package/rocket-preset-markdown-directive) - Add your own custom md code block directives
|
|
||||||
- [rocket-preset-playground-elements](https://www.npmjs.com/package/rocket-preset-playground-elements) - Live code editors that run in-browser
|
|
||||||
- [rocket-preset-slide-decks](https://www.npmjs.com/package/rocket-preset-slide-decks) - Slide decks in Markdown and HTML
|
|
||||||
- [rocket-preset-webcomponents-dev](https://www.npmjs.com/package/rocket-preset-webcomponents-dev) - Live code editors that run on webcomponents.dev
|
|
||||||
|
|
||||||
> Want your plugin listed here? Please [create a PR](https://github.com/modernweb-dev/rocket/edit/main/docs/guides/presets/getting-started.md)!
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '10--guides/20--presets/20--overriding.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
# Overriding
|
|
||||||
|
|
||||||
All loaded presets will be combined but you can override each file.
|
|
||||||
|
|
||||||
Take a look at `docs/_merged_includes` and override what you want to override by placing the same filename into `_includes`.
|
|
||||||
|
|
||||||
For example, to override the css files loaded in the `<head>`,
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cp docs/_merged_includes/_joiningBlocks/head/40-stylesheets.njk \
|
|
||||||
docs/_includes/_joiningBlocks/head/40-stylesheets.njk
|
|
||||||
```
|
|
||||||
|
|
||||||
then edit the file to suit your needs.
|
|
||||||
|
|
||||||
Also works for `_assets`, `_data` ...
|
|
||||||
|
|
||||||
<inline-notification type="warning">
|
|
||||||
|
|
||||||
If you don't [add `.eleventyignore`](/guides/first-pages/getting-started/#setup), you may receive error messages when running `rocket build`.
|
|
||||||
|
|
||||||
</inline-notification>
|
|
||||||
|
|
||||||
```js script
|
|
||||||
import '@rocket/launch/inline-notification/inline-notification.js';
|
|
||||||
```
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '10--guides/20--presets/index.rocket.js';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
|
|
||||||
import { html } from 'lit-html';
|
|
||||||
export default () => html`
|
|
||||||
<h1>Presets</h1>
|
|
||||||
<meta name="menu:exclude" content="true" />
|
|
||||||
`;
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '10--guides/30--configuration/10--getting-started.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
# Getting Started
|
|
||||||
|
|
||||||
The main config file is `rocket.config.js` or `rocket.config.mjs`.
|
|
||||||
|
|
||||||
It typically looks something like this
|
|
||||||
|
|
||||||
```js
|
|
||||||
import { rocketLaunch } from '@rocket/launch';
|
|
||||||
import { rocketBlog } from '@rocket/blog';
|
|
||||||
import { rocketSearch } from '@rocket/search';
|
|
||||||
import { absoluteBaseUrlNetlify } from '@rocket/core/helpers';
|
|
||||||
|
|
||||||
export default /** @type {Partial<import('@rocket/cli').RocketCliOptions>} */ ({
|
|
||||||
presets: [rocketLaunch(), rocketBlog(), rocketSearch()],
|
|
||||||
absoluteBaseUrl: absoluteBaseUrlNetlify('http://localhost:8080'),
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
The Plugins Manager helps you register and execute your plugins across the various Rocket components - Rollup, Web Dev Server, Eleventy, and Markdown. It replaces the specific registration/execution call in a given plugin system by an intent to use that plugin.
|
|
||||||
|
|
||||||
## Adding Remark/Unified Plugins
|
|
||||||
|
|
||||||
If you want to add a plugin to the Markdown processing you can use `setupUnifiedPlugins`.
|
|
||||||
|
|
||||||
<!-- prettier-ignore-start -->
|
|
||||||
```js
|
|
||||||
import emoji from 'remark-emoji';
|
|
||||||
import { addPlugin } from 'plugins-manager';
|
|
||||||
|
|
||||||
/** @type {Partial<import('@rocket/cli').RocketCliOptions>} */
|
|
||||||
export default ({
|
|
||||||
setupUnifiedPlugins: [addPlugin({ location: 'markdown', name: 'emoji', plugin: emoji })],
|
|
||||||
});
|
|
||||||
```
|
|
||||||
<!-- prettier-ignore-end -->
|
|
||||||
|
|
||||||
For plugins that should handle the Markdown <abbr title="Abstract Syntax Tree">AST</abbr> you should use `addPlugin({ location: 'markdown', name: 'my-plugin', plugin: MyPlugin})`. <br>
|
|
||||||
While for the rehype AST you should use `addPlugin({ location: 'remark2rehype', name: 'my-plugin', plugin: MyPlugin})`.
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '10--guides/30--configuration/index.rocket.js';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
|
|
||||||
import { html } from 'lit-html';
|
|
||||||
export default () => html`<h1>Configuration</h1>
|
|
||||||
<meta name="menu:exclude" content="true" />`;
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '10--guides/40--go-live/10--overview.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
# Overview
|
|
||||||
|
|
||||||
A few things are usually needed before going live "for real".
|
|
||||||
|
|
||||||
## Add a Not Found Page
|
|
||||||
|
|
||||||
When a user enters a URL that does not exist, a "famous" 404 Page Not Found error occurs.
|
|
||||||
Many servers are configured to handle this automatically and to serve a 404.html page instead.
|
|
||||||
|
|
||||||
The [Rocket Launch preset](../../docs/presets/launch.md) ships a default 404 template you can use.
|
|
||||||
|
|
||||||
To enable it, you need to create a `404.md` and use the 404 layout.
|
|
||||||
|
|
||||||
👉 `docs/404.md`
|
|
||||||
|
|
||||||
```markdown copy
|
|
||||||
---
|
|
||||||
layout: layout-404
|
|
||||||
permalink: 404.html
|
|
||||||
---
|
|
||||||
```
|
|
||||||
|
|
||||||
This results in a `404.html` page, which will do nothing by itself. But many hosting services like netlify or firebase, for example will redirect 404s to this `404.html` by default.
|
|
||||||
|
|
||||||
If the hosting provider doesn't already do this, then you may be able to accomplish it via some settings for example by using a `.htaccess` file in case of an apache server.
|
|
||||||
|
|
||||||
## Add a Sitemap
|
|
||||||
|
|
||||||
A sitemap can be used to inform search engines or services about the pages your site has.
|
|
||||||
|
|
||||||
You can create one by adding this file:
|
|
||||||
|
|
||||||
👉 `docs/sitemap.njk`
|
|
||||||
|
|
||||||
```markdown copy
|
|
||||||
---
|
|
||||||
layout: layout-raw
|
|
||||||
permalink: /sitemap.xml
|
|
||||||
eleventyExcludeFromCollections: true
|
|
||||||
---
|
|
||||||
|
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
||||||
{% raw %}{% for page in collections.all %}
|
|
||||||
{%- if page.url !== '/404.html' -%}
|
|
||||||
<url>
|
|
||||||
<loc>{{ rocketConfig.absoluteBaseUrl }}{{ page.url | url }}</loc>
|
|
||||||
<lastmod>{{ page.date.toISOString() }}</lastmod>
|
|
||||||
<changefreq>{{ page.data.changeFreq if page.data.changeFreq else "monthly" }}</changefreq>
|
|
||||||
</url>
|
|
||||||
{%- endif -%}
|
|
||||||
{% endfor %}{% endraw %}
|
|
||||||
</urlset>
|
|
||||||
```
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '10--guides/40--go-live/20--social-media.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
# Social Media
|
|
||||||
|
|
||||||
Having a nice preview image for social media can be very helpful.
|
|
||||||
For that reason Rocket creates those automatically with the title, parent title, section and your logo.
|
|
||||||
|
|
||||||
It will look like this but with your logo:
|
|
||||||
|
|
||||||
There are multiple ways you can modify it.
|
|
||||||
|
|
||||||
Note: If your logo has an `<?xml>` tag it will throw an error as it will be inlined into this SVG and nested XML tags are not allowed.
|
|
||||||
|
|
||||||
## Setting it via Front Matter
|
|
||||||
|
|
||||||
You can create your own image and link it with something like this
|
|
||||||
|
|
||||||
```markdown copy
|
|
||||||
---
|
|
||||||
socialMediaImage: path/to/my/image.png
|
|
||||||
---
|
|
||||||
```
|
|
||||||
|
|
||||||
## Providing Your Own Text
|
|
||||||
|
|
||||||
Sometimes extracting the title + title of parent is not enough but you still want to use the "default image".
|
|
||||||
|
|
||||||
You can create an `11tydata.cjs` file next to your page. If your page is `docs/guides/overview.md` then you create a `docs/guides/overview.11tydata.cjs`.
|
|
||||||
|
|
||||||
In there you can use the default `createSocialImage` but provide your own values.
|
|
||||||
|
|
||||||
```js copy
|
|
||||||
const { createSocialImage } = require('@rocket/cli');
|
|
||||||
|
|
||||||
module.exports = async function () {
|
|
||||||
const socialMediaImage = await createSocialImage({
|
|
||||||
title: 'Learning Rocket',
|
|
||||||
subTitle: 'Have a website',
|
|
||||||
subTitle2: 'in 5 Minutes',
|
|
||||||
footer: 'Rocket Guides',
|
|
||||||
// you can also override the svg only for this page by providing
|
|
||||||
// createSocialImageSvg: async () => '{%raw%}<svg>...</svg>{%endraw%}'
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
socialMediaImage,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
## Override the Default Image
|
|
||||||
|
|
||||||
Often you want to have a unique style for your social media images.
|
|
||||||
For that you can provide your own function which returns a string of an SVG to render the image.
|
|
||||||
|
|
||||||
👉 `rocket.config.js`
|
|
||||||
|
|
||||||
<!-- prettier-ignore-start -->
|
|
||||||
```js copy
|
|
||||||
import { adjustPluginOptions } from 'plugins-manager';
|
|
||||||
|
|
||||||
/** @type {import('@rocket/cli').RocketCliOptions} */
|
|
||||||
export default ({
|
|
||||||
setupEleventyComputedConfig: [
|
|
||||||
adjustPluginOptions('socialMediaImage', {
|
|
||||||
createSocialImageSvg: async ({
|
|
||||||
title = '',
|
|
||||||
subTitle = '',
|
|
||||||
subTitle2 = '',
|
|
||||||
footer = '',
|
|
||||||
logo = '',
|
|
||||||
}) => {
|
|
||||||
let svgStr = `
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 630" style="fill: #ecedef;">
|
|
||||||
<defs/>
|
|
||||||
<rect width="100%" height="100%" fill="#38393e"/>
|
|
||||||
<g transform="matrix(0.45, 0, 0, 0.45, 300, 60)">${logo}</g>
|
|
||||||
<g style="
|
|
||||||
font-size: 70px;
|
|
||||||
text-anchor: middle;
|
|
||||||
font-family: 'Bitstream Vera Sans','Helvetica',sans-serif;
|
|
||||||
font-weight: 700;
|
|
||||||
">
|
|
||||||
<text x="50%" y="470">
|
|
||||||
${title}
|
|
||||||
</text>
|
|
||||||
<text x="50%" y="520" style="font-size: 30px;">
|
|
||||||
${subTitle}
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<text x="10" y="620" style="font-size: 30px; fill: gray;">
|
|
||||||
${footer}
|
|
||||||
</text>
|
|
||||||
</svg>
|
|
||||||
`;
|
|
||||||
return svgStr;
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
```
|
|
||||||
<!-- prettier-ignore-end -->
|
|
||||||
|
|
||||||
## Using an SVG File as a src with Nunjucks
|
|
||||||
|
|
||||||
If you have multiple variations it may be easier to save them as SVG files and use a template system.
|
|
||||||
|
|
||||||
<!-- prettier-ignore-start -->
|
|
||||||
<code-tabs default-tab="rocket.config.js">
|
|
||||||
|
|
||||||
```js tab rocket.config.js
|
|
||||||
import { adjustPluginOptions } from 'plugins-manager';
|
|
||||||
|
|
||||||
/** @type {import('@rocket/cli').RocketCliOptions} */
|
|
||||||
export default ({
|
|
||||||
setupEleventyComputedConfig: [
|
|
||||||
adjustPluginOptions('socialMediaImage', {
|
|
||||||
createSocialImageSvg: async (args = {}) => {
|
|
||||||
const svgBuffer = await fs.promises.readFile('/path/to/your/template.svg');
|
|
||||||
const svg = logoBuffer.toString();
|
|
||||||
return nunjucks.renderString(svg, args);
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
```svg tab /path/to/your/template.svg
|
|
||||||
{%raw%}<svg xmlns="http://www.w3.org/2000/svg" fill="#e63946" viewBox="0 0 511.998 511.998">
|
|
||||||
<text font-family="'Open Sans', sans-serif" font-size="39" transform="translate(422.99 408.53)">
|
|
||||||
<tspan x="-89.26" y="12.25">{{ title }}</tspan>
|
|
||||||
</text>
|
|
||||||
<path d="M98.649 430.256c-46.365 28.67-71.17 30.939-78.916 23.51-7.75-7.433-6.519-32.307 20.182-79.832 24.953-44.412 65.374-96.693 113.818-147.211l-11.279-10.817c-49.33 51.442-90.583 104.845-116.163 150.373-19.228 34.22-37.848 79.134-17.375 98.766 5.84 5.6 13.599 7.935 22.484 7.935 22.269 0 51.606-14.677 75.469-29.432 44.416-27.464 96.044-70.919 145.373-122.362l-11.279-10.817c-48.446 50.519-98.987 93.095-142.314 119.887zM254.734 294.95l-18.47-17.71 10.816-11.281 18.47 17.71zM285.516 324.473l-18.47-17.71 10.816-11.28 18.47 17.71zM315.543 317.807l-73.886-70.847 10.816-11.28 73.886 70.846zM500.916 41.287c-7.769 1.59-76.412 16.062-93.897 34.294l-50.728 52.899-114.703-3.629-39.198 40.876 79.28 40.569-21.755 22.687 72.848 69.858 21.755-22.687 43.857 77.51 39.197-40.876-8.433-114.451 50.727-52.899c17.485-18.234 29.067-87.422 30.331-95.251l1.801-11.169-11.082 2.269zM228.209 161.383l19.842-20.692 93.688 2.964-48.775 50.864-64.755-33.136zm173.423 166.303l-35.822-63.308 48.776-50.865 6.886 93.482-19.84 20.691zm-69.334-50.943l-50.287-48.223L412.89 92.037l50.288 48.223-130.88 136.483zm140.711-148.707l-48.316-46.334c14.54-8.427 44.787-17.217 68.076-22.632-4.433 23.497-11.949 54.085-19.76 68.966z"/>
|
|
||||||
<path d="M326.335 257.25l-24.628-23.614 10.816-11.28 24.628 23.615zM431.385 134.414l-11.808 12.315-11.28-10.816 11.808-12.315zM401.838 165.183l-11.28-10.816 11.807-12.314 11.28 10.816zM384.121 183.66l-11.28-10.816 11.807-12.314 11.28 10.816zM175.19 184.515l11.051 11.05-23.582 23.582-11.05-11.05zM190.903 168.796l11.05 11.052-7.863 7.86-11.05-11.052z"/>
|
|
||||||
</svg>{%endraw%}
|
|
||||||
```
|
|
||||||
|
|
||||||
</code-tabs>
|
|
||||||
<!-- prettier-ignore-end -->
|
|
||||||
|
|
||||||
## Enabling / Disabling
|
|
||||||
|
|
||||||
Generating images from SVG is quite fast but it can still add that's why by default during `rocket start` there will be no social media images created.
|
|
||||||
|
|
||||||
If you with so create them also during start you can
|
|
||||||
|
|
||||||
<!-- prettier-ignore-start -->
|
|
||||||
```js copy
|
|
||||||
export default ({
|
|
||||||
start: {
|
|
||||||
createSocialMediaImages: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
```
|
|
||||||
<!-- prettier-ignore-end -->
|
|
||||||
|
|
||||||
Similarly, if you never want to create social media images even during build then you can globally disable it via
|
|
||||||
|
|
||||||
<!-- prettier-ignore-start -->
|
|
||||||
```js copy
|
|
||||||
export default ({
|
|
||||||
createSocialMediaImages: true,
|
|
||||||
});
|
|
||||||
```
|
|
||||||
<!-- prettier-ignore-end -->
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '10--guides/40--go-live/index.rocket.js';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
|
|
||||||
import { html } from 'lit-html';
|
|
||||||
export default () => html`<h1>Go Live</h1>
|
|
||||||
<meta name="menu:exclude" content="true" />`;
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '10--guides/index.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
# Learning Rocket
|
|
||||||
|
|
||||||
<meta name="menu:link.text" content="Guides">
|
|
||||||
|
|
||||||
Rocket helps you generate static pages from Markdown files while giving you the flexibility to sprinkle in some JavaScript where needed.
|
|
||||||
|
|
||||||
- [First Pages](./first-pages/getting-started/) Learn how to bootstrap and run a Rocket site
|
|
||||||
- [Adding Pages](./first-pages/adding-pages/) Create your own content pages
|
|
||||||
- [Linking](./first-pages/link-to-other-pages/) Link between yuor markdown pages
|
|
||||||
- [Managing Sidebar](./first-pages/manage-sidebar/) Customize your site's navigation
|
|
||||||
- [Use JavaScript](./first-pages/use-javascript/) Write inline scripts in markdown
|
|
||||||
- [URLs](./first-pages/urls/) Customize your pages' permalinks
|
|
||||||
- [Layouts](./first-pages/layouts/) Give your page a custom layout
|
|
||||||
- [Presets](./presets/getting-started/) Customize Rocket with config presets
|
|
||||||
- [Overriding](./presets/overriding/) Override preset templates
|
|
||||||
- [Using Templates](./presets/using-templates/) Make use of preset templates
|
|
||||||
- [Create Your Own](./presets/create-your-own/getting-started/) Write and publish your own presets
|
|
||||||
- [Configuration](./configuration/getting-started/) Make Rocket your own
|
|
||||||
- [Go Live](./go-live/overview/) Publish your site
|
|
||||||
- [Social Media](./go-live/social-media/) Generate social images
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '20--docs/10--configuration/10--overview.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
# Overview
|
|
||||||
|
|
||||||
The configuration file is `rocket.config.js` or `rocket.config.mjs`.
|
|
||||||
|
|
||||||
The config files consist of the following parts:
|
|
||||||
|
|
||||||
```js
|
|
||||||
import { rocketLaunch } from '@rocket/launch';
|
|
||||||
|
|
||||||
/** @type {import('rocket/cli').RocketCliConfig} */
|
|
||||||
export default {
|
|
||||||
presets: [rocketLaunch()],
|
|
||||||
emptyOutputDir: true,
|
|
||||||
pathPrefix: 'subfolder-only-for-build',
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
Rocket is primarily build around plugins for each of its systems.
|
|
||||||
|
|
||||||
New plugins can be added and all default plugins can be adjusted or even removed by using the following functions.
|
|
||||||
|
|
||||||
```js
|
|
||||||
/** @type {import('rocket/cli').RocketCliConfig} */
|
|
||||||
export default {
|
|
||||||
// add a rollup plugins to the web dev server (will be wrapped with @web/dev-server-rollup) AND the rollup build (e.g. enable json importing)
|
|
||||||
setupDevServerAndBuildPlugins: [],
|
|
||||||
|
|
||||||
// add a plugin to the web dev server (will not be wrapped) (e.g. esbuild for TypeScript)
|
|
||||||
setupDevServerPlugins: [],
|
|
||||||
|
|
||||||
// add a plugin to the rollup build (e.g. optimization steps)
|
|
||||||
setupBuildPlugins: [],
|
|
||||||
|
|
||||||
// add a plugin to the cli (e.g. a new command like "rocket my-command")
|
|
||||||
setupCliPlugins: [],
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
## Adding Rollup Plugins
|
|
||||||
|
|
||||||
For some projects you might want to enable non-standard behaviors like importing JSON files as JavaScript.
|
|
||||||
|
|
||||||
```js
|
|
||||||
import data from './data.json';
|
|
||||||
```
|
|
||||||
|
|
||||||
You can accomplish this with Rollup and dev server plugins. Make sure to add both the dev-server plugin as well as the Rollup plugin, so that the behaviors is the same during development as it is in the production build.
|
|
||||||
|
|
||||||
For these cases you can use `setupDevServerAndBuildPlugins`, which will automatically add the plugin for you to both Rollup and dev-server:
|
|
||||||
|
|
||||||
```js
|
|
||||||
import json from '@rollup/plugin-json';
|
|
||||||
import { addPlugin } from 'plugins-manager';
|
|
||||||
|
|
||||||
/** @type {import('@rocket/cli').RocketCliOptions} */
|
|
||||||
export default {
|
|
||||||
setupDevServerAndBuildPlugins: [
|
|
||||||
addPlugin({ name: 'json', plugin: json, location: 'top', options: { my: 'settings' } }),
|
|
||||||
],
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
This will add the Rollup plugin `json` with the id `json` at the top of the plugin list of Rollup and the dev server. It needs to be at the top so further plugins down the line can work with JSON imports.
|
|
||||||
For the Dev Server the plugins are automatically wrapped by `@web/dev-server-rollup`. Note that [not all Rollup plugins](https://modern-web.dev/docs/dev-server/plugins/rollup/#compatibility-with-rollup-plugins) will work with the dev-server.
|
|
||||||
|
|
||||||
## Modifying Options of Plugins
|
|
||||||
|
|
||||||
All plugins which are either default or are added via a preset can still be adjusted by using `adjustPluginOptions`.
|
|
||||||
|
|
||||||
```js
|
|
||||||
import { adjustPluginOptions } from 'plugins-manager';
|
|
||||||
|
|
||||||
/** @type {import('@rocket/cli').RocketCliOptions} */
|
|
||||||
export default {
|
|
||||||
setupDevServerAndBuildPlugins: [adjustPluginOptions('json', { my: 'overwrite settings' })],
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
## Advanced
|
|
||||||
|
|
||||||
Sometimes you need even more control over specific settings.
|
|
||||||
|
|
||||||
### Rollup
|
|
||||||
|
|
||||||
For example if you wanna add an `acron` plugin to rollup
|
|
||||||
|
|
||||||
```js
|
|
||||||
import { importAssertions } from 'acorn-import-assertions';
|
|
||||||
|
|
||||||
/** @type {import('rocket/cli').RocketCliConfig} */
|
|
||||||
export default {
|
|
||||||
rollup: config => ({
|
|
||||||
...config,
|
|
||||||
acornInjectPlugins: [importAssertions],
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
```
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '20--docs/10--configuration/20--service-worker.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
# Service Worker
|
|
||||||
|
|
||||||
Rocket does come with a default service worker that will
|
|
||||||
|
|
||||||
- cache already visited pages
|
|
||||||
- cache assets of visited pages (up to 100 files then it replaces older entries)
|
|
||||||
- reload the page if a newer html page version is available on service worker activation
|
|
||||||
|
|
||||||
## Adjusting the file name
|
|
||||||
|
|
||||||
Changing the service worker file name can be quite a hassle so you can adjust generate file name via a config.
|
|
||||||
|
|
||||||
👉 `rocket.config.js`
|
|
||||||
|
|
||||||
```js
|
|
||||||
/** @type {import('rocket/cli').RocketCliConfig} */
|
|
||||||
export default {
|
|
||||||
serviceWorkerName: 'my-service-worker-name.js',
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
## Meet the Service Worker
|
|
||||||
|
|
||||||
The default service worker will work for many scenarios however your needs my vary.
|
|
||||||
To enable different service worker strategies you can replace the default service worker code by providing a file at `_assets/service-worker.js`.
|
|
||||||
This file will be auto transformed and generated in the root of the website using the defined `serviceWorkerName`.
|
|
||||||
|
|
||||||
For inspiration, you can take a look at the default config.
|
|
||||||
|
|
||||||
[https://github.com/modernweb-dev/rocket/blob/main/packages/cli/preset/\_assets/service-worker.js](https://github.com/modernweb-dev/rocket/blob/main/packages/cli/preset/_assets/service-worker.js)
|
|
||||||
|
|
||||||
Be sure to check out [workbox](https://developers.google.com/web/tools/workbox) for more service worker magic.
|
|
||||||
|
|
||||||
And if you wanna have a 30 minutes crash course we highly recommend the talk [Service Workers For The Rest Of Us](https://vimeo.com/362260166) by [Philip Walton](https://twitter.com/philwalton).
|
|
||||||
|
|
||||||
## Registration
|
|
||||||
|
|
||||||
The registration happens via another file that you can also overwrite at `_assets/scripts/registerServiceWorker.js`.
|
|
||||||
|
|
||||||
Below you find the default implementation.
|
|
||||||
|
|
||||||
<!-- prettier-ignore-start -->
|
|
||||||
```js
|
|
||||||
{{ '/_assets/scripts/registerServiceWorker.js' | asset | toAbsPath | inlineFilePath; }}
|
|
||||||
```
|
|
||||||
<!-- prettier-ignore-end -->
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '20--docs/10--configuration/index.rocket.js';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
|
|
||||||
import { html } from 'lit-html';
|
|
||||||
export default () =>
|
|
||||||
html`<h1>Configuration</h1>
|
|
||||||
<meta name="menu:exclude" content="true" />`;
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '20--docs/20--presets/10--joining-blocks.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
# Joining Blocks
|
|
||||||
|
|
||||||
The template system allows for a very granular control of how individual parts will be merged, overwritten or reorderd.
|
|
||||||
|
|
||||||
As a preset you may want to add this to your layout.
|
|
||||||
|
|
||||||
{% raw %}
|
|
||||||
|
|
||||||
```jinja2
|
|
||||||
<footer id="main-footer">
|
|
||||||
{% for blockName, blockPath in _joiningBlocks.footer %}
|
|
||||||
{% include blockPath %}
|
|
||||||
{% endfor %}
|
|
||||||
</footer>
|
|
||||||
```
|
|
||||||
|
|
||||||
{% endraw %}
|
|
||||||
|
|
||||||
This will now render all templates within `_includes/_joiningBlocks/footer/*`.
|
|
||||||
|
|
||||||
## Adding content without overriding
|
|
||||||
|
|
||||||
Let's assume we have a preset with the following files
|
|
||||||
|
|
||||||
👉 `_includes/_joiningBlocks/footer/10-first.njk`
|
|
||||||
|
|
||||||
```html
|
|
||||||
<p>first</p>
|
|
||||||
```
|
|
||||||
|
|
||||||
👉 `_includes/_joiningBlocks/footer/20-second.njk`
|
|
||||||
|
|
||||||
```html
|
|
||||||
<p>second</p>
|
|
||||||
```
|
|
||||||
|
|
||||||
And it produces this in your website
|
|
||||||
|
|
||||||
```html
|
|
||||||
<footer>
|
|
||||||
<p>first</p>
|
|
||||||
<p>second</p>
|
|
||||||
</footer>
|
|
||||||
```
|
|
||||||
|
|
||||||
Now we can add a file which will insert content without needing to overwrite any of the preset file.
|
|
||||||
|
|
||||||
👉 `docs/_includes/_joiningBlocks/footer/15-in-between.njk`
|
|
||||||
|
|
||||||
```html
|
|
||||||
<p>in-between</p>
|
|
||||||
```
|
|
||||||
|
|
||||||
the final output will be
|
|
||||||
|
|
||||||
```html
|
|
||||||
<footer>
|
|
||||||
<p>first</p>
|
|
||||||
<p>in-between</p>
|
|
||||||
<p>second</p>
|
|
||||||
</footer>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Overriding Content
|
|
||||||
|
|
||||||
Now if you want to overwrite you can use the same filename.
|
|
||||||
|
|
||||||
👉 `docs/_includes/_joiningBlocks/footer/10-first.njk`
|
|
||||||
|
|
||||||
```html
|
|
||||||
<p>updated first</p>
|
|
||||||
```
|
|
||||||
|
|
||||||
the final output will be
|
|
||||||
|
|
||||||
```html
|
|
||||||
<footer>
|
|
||||||
<p>updated first</p>
|
|
||||||
<p>second</p>
|
|
||||||
</footer>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Reordering and Overriding
|
|
||||||
|
|
||||||
Sometimes you wanna reorder when you overwrite as well
|
|
||||||
|
|
||||||
👉 `docs/_includes/_joiningBlocks/footer/30-first.njk`
|
|
||||||
|
|
||||||
```html
|
|
||||||
<p>first</p>
|
|
||||||
```
|
|
||||||
|
|
||||||
the final output will be
|
|
||||||
|
|
||||||
```html
|
|
||||||
<footer>
|
|
||||||
<p>second</p>
|
|
||||||
<p>first</p>
|
|
||||||
</footer>
|
|
||||||
```
|
|
||||||
|
|
||||||
Note: Reordering always requires you to overwrite as well.
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '20--docs/20--presets/20--launch/index.rocket.js';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
|
|
||||||
import { html } from 'lit-html';
|
|
||||||
export default () =>
|
|
||||||
html`<h1>Launch</h1>
|
|
||||||
<meta name="menu:exclude" content="true" />`;
|
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '20--docs/20--presets/20--launch/overview.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
```js server
|
|
||||||
import { html } from 'lit-html';
|
|
||||||
```
|
|
||||||
|
|
||||||
# Overview
|
|
||||||
|
|
||||||
Rocket comes with a preset you will love. Simple, responsive and behaving like native, it sure is going to be a hit among your users.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
Install `@rocket/launch` from the NPM repository using your favourite package manager.
|
|
||||||
|
|
||||||
<code-tabs collection="package-managers" default-tab="npm" align="end">
|
|
||||||
|
|
||||||
```bash tab npm
|
|
||||||
npm i @rocket/launch
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash tab yarn
|
|
||||||
yarn add @rocket/launch
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash tab pnpm
|
|
||||||
pnpm add @rocket/launch
|
|
||||||
```
|
|
||||||
|
|
||||||
</code-tabs>
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
👉 `rocket.config.js`
|
|
||||||
|
|
||||||
```js
|
|
||||||
import { rocketLaunch } from '@rocket/launch';
|
|
||||||
|
|
||||||
/** @type {import('rocket/cli').RocketCliConfig} */
|
|
||||||
export default {
|
|
||||||
presets: [rocketLaunch()],
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
## Data
|
|
||||||
|
|
||||||
You can define your own data for the available Layouts.
|
|
||||||
|
|
||||||
## Inline Notification
|
|
||||||
|
|
||||||
```js script
|
|
||||||
import '@rocket/launch/inline-notification/inline-notification.js';
|
|
||||||
```
|
|
||||||
|
|
||||||
Launch ships with `<inline-notification>`, a custom element that applies some styles similar to "info boxes". The element works for `<noscript>` users as well, as long as you don't [override](/guides/presets/overriding/) the default `noscript.css` file.
|
|
||||||
|
|
||||||
To add an inline notification you need to remember to import the element definition:
|
|
||||||
|
|
||||||
````md
|
|
||||||
```js script
|
|
||||||
import '@rocket/launch/inline-notification/inline-notification.js';
|
|
||||||
```
|
|
||||||
````
|
|
||||||
|
|
||||||
Then you can add your notification to the page. If you want to write the notification's content using markdown, just pad the opening and closing tags with empty lines.
|
|
||||||
|
|
||||||
There are three varieties of `<inline-notification>`, "tip", "warning", and "danger"
|
|
||||||
|
|
||||||
<style>
|
|
||||||
#inline-notifications::part(tab) {
|
|
||||||
text-transform: capitalize;
|
|
||||||
}
|
|
||||||
#inline-notifications code-tab::part(content) {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
gap: 6px;
|
|
||||||
}
|
|
||||||
#inline-notifications code-copy::part(copy-button) {
|
|
||||||
position: absolute;
|
|
||||||
top: 10px;
|
|
||||||
border-radius: 6px;
|
|
||||||
border: 1px solid var(--primary-lines-color);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<inline-notification type="tip">
|
|
||||||
|
|
||||||
Take a tip from me
|
|
||||||
|
|
||||||
</inline-notification>
|
|
||||||
|
|
||||||
```md
|
|
||||||
<inline-notification type="tip">
|
|
||||||
|
|
||||||
Take a tip from me
|
|
||||||
|
|
||||||
</inline-notification>
|
|
||||||
```
|
|
||||||
|
|
||||||
<inline-notification type="warning">
|
|
||||||
|
|
||||||
Be _sure_ about this...
|
|
||||||
|
|
||||||
</inline-notification>
|
|
||||||
|
|
||||||
```md
|
|
||||||
<inline-notification type="warning">
|
|
||||||
|
|
||||||
Be _sure_ about this...
|
|
||||||
|
|
||||||
</inline-notification>
|
|
||||||
```
|
|
||||||
|
|
||||||
<inline-notification type="danger">
|
|
||||||
|
|
||||||
You **really** shouldn't!
|
|
||||||
|
|
||||||
</inline-notification>
|
|
||||||
|
|
||||||
```md
|
|
||||||
<inline-notification type="danger">
|
|
||||||
|
|
||||||
You **really** shouldn't!
|
|
||||||
|
|
||||||
</inline-notification>
|
|
||||||
```
|
|
||||||
|
|
||||||
### Modify the Title
|
|
||||||
|
|
||||||
The notification title defaults to it's type. You can write a custom title with the `title` attribute.
|
|
||||||
|
|
||||||
<inline-notification type="tip" title="success">
|
|
||||||
|
|
||||||
I am a success message
|
|
||||||
|
|
||||||
</inline-notification>
|
|
||||||
|
|
||||||
```md
|
|
||||||
<inline-notification type="tip" title="success">
|
|
||||||
|
|
||||||
I am a success message
|
|
||||||
|
|
||||||
</inline-notification>
|
|
||||||
```
|
|
||||||
|
|
||||||
<inline-notification type="warning">
|
|
||||||
|
|
||||||
The `title` attribute does not change the title for `<noscript>` users, so don't include any critical information in it.
|
|
||||||
|
|
||||||
</inline-notification>
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '20--docs/20--presets/30--search/index.rocket.js';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
|
|
||||||
import { html } from 'lit-html';
|
|
||||||
export default () =>
|
|
||||||
html`<h1>Search</h1>
|
|
||||||
<meta name="menu:exclude" content="true" />`;
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '20--docs/20--presets/30--search/overview.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
# Overview
|
|
||||||
|
|
||||||
Add a search for all your static content.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
<code-tabs collection="package-managers" default-tab="npm" align="end">
|
|
||||||
|
|
||||||
```bash tab npm
|
|
||||||
npm i @rocket/search
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash tab yarn
|
|
||||||
yarn add @rocket/search
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash tab pnpm
|
|
||||||
pnpm add @rocket/search
|
|
||||||
```
|
|
||||||
|
|
||||||
</code-tabs>
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
👉 `rocket.config.js`
|
|
||||||
|
|
||||||
```js
|
|
||||||
import { rocketSearch } from '@rocket/search';
|
|
||||||
|
|
||||||
/** @type {import('rocket/cli').RocketCliConfig} */
|
|
||||||
export default {
|
|
||||||
presets: [rocketSearch()],
|
|
||||||
};
|
|
||||||
```
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '20--docs/20--presets/40--blog.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
# Blog
|
|
||||||
|
|
||||||
Enable writing blog posts within your Rocket site.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
<code-tabs collection="package-managers" default-tab="npm" align="end">
|
|
||||||
|
|
||||||
```bash tab npm
|
|
||||||
npm i @rocket/blog
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash tab yarn
|
|
||||||
yarn add @rocket/blog
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash tab pnpm
|
|
||||||
pnpm add @rocket/blog
|
|
||||||
```
|
|
||||||
|
|
||||||
</code-tabs>
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
👉 `rocket.config.js`
|
|
||||||
|
|
||||||
```js
|
|
||||||
import { rocketBlog } from '@rocket/blog';
|
|
||||||
|
|
||||||
/** @type {import('rocket/cli').RocketCliConfig} */
|
|
||||||
export default {
|
|
||||||
presets: [rocketBlog()],
|
|
||||||
};
|
|
||||||
```
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '20--docs/20--presets/index.rocket.js';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
|
|
||||||
import { html } from 'lit-html';
|
|
||||||
export default () =>
|
|
||||||
html`<h1>Presets</h1>
|
|
||||||
<meta name="menu:exclude" content="true" />`;
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '20--docs/30--markdown-javascript/30--story.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
# Story
|
|
||||||
|
|
||||||
You can showcase live running code by annotating a code block with `js story`.
|
|
||||||
|
|
||||||
```js script
|
|
||||||
import { html } from '@mdjs/mdjs-story';
|
|
||||||
```
|
|
||||||
|
|
||||||
````md
|
|
||||||
```js script
|
|
||||||
import { html } from '@mdjs/mdjs-story';
|
|
||||||
```
|
|
||||||
|
|
||||||
```js story
|
|
||||||
export const foo = () => html` <p>my html</p> `;
|
|
||||||
```
|
|
||||||
````
|
|
||||||
|
|
||||||
will result in
|
|
||||||
|
|
||||||
```js story
|
|
||||||
export const foo = () => html` <p>my html</p> `;
|
|
||||||
```
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '20--docs/30--markdown-javascript/index.rocket.js';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
|
|
||||||
import { html } from 'lit-html';
|
|
||||||
export default () =>
|
|
||||||
html`<h1>Markdown Javascript</h1>
|
|
||||||
<meta name="menu:exclude" content="true" />`;
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '20--docs/50--tools/index.rocket.js';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
|
|
||||||
import { html } from 'lit-html';
|
|
||||||
export default () =>
|
|
||||||
html`<h1>Tools</h1>
|
|
||||||
<meta name="menu:exclude" content="true" />`;
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '20--docs/index.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
<meta name="menu:link.text" content="Docs" />
|
|
||||||
|
|
||||||
# Documentation
|
|
||||||
|
|
||||||
Here you will find all the details for each of the packages/systems we offer.
|
|
||||||
|
|
||||||
## Contents
|
|
||||||
|
|
||||||
- [Configuration](./configuration/)
|
|
||||||
- [Overview](./configuration/overview/)
|
|
||||||
- [Computed Config](./configuration/computed-config/)
|
|
||||||
- [Service Worker](./configuration/service-worker/)
|
|
||||||
- [Images](./configuration/images/)
|
|
||||||
- [Presets](./presets/)
|
|
||||||
- [Joining Blocks](./presets/joining-blocks/)
|
|
||||||
- [`@rocket/launch`](./presets/launch/)
|
|
||||||
- [`@rocket/search`](./presets/search/)
|
|
||||||
- [`@rocket/blog`](./presets/blog/)
|
|
||||||
- [Markdown JavaScript](./markdown-javascript/)
|
|
||||||
- [Overview](./markdown-javascript/overview/)
|
|
||||||
- [Preview](./markdown-javascript/preview/)
|
|
||||||
- [Story](./markdown-javascript/story/)
|
|
||||||
- [Eleventy Plugins](./eleventy-plugins/)
|
|
||||||
- [Markdown JavaScript (mdjs)](./eleventy-plugins/mdjs-unified/)
|
|
||||||
- [Tools](./tools/)
|
|
||||||
- [Plugins Manager](./tools/plugins-manager/)
|
|
||||||
- [Rollup Config](./tools/rollup-config/)
|
|
||||||
- [Check HTML Links ](./tools/check-html-links/)
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = '30--blog/index.rocket.js';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
|
|
||||||
import { html } from 'lit-html';
|
|
||||||
|
|
||||||
export default () => html`
|
|
||||||
<h1>Rocket Blog</h1>
|
|
||||||
<meta name="menu:link.text" content="Blog" />
|
|
||||||
<p>
|
|
||||||
Discover articles from the core team and contributors about Rocket, tips and tricks included!
|
|
||||||
</p>
|
|
||||||
`;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = 'about/index.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
<meta name="menu:exclude" content="true" />
|
|
||||||
|
|
||||||
# About
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = 'about/slack.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
# Slack
|
|
||||||
|
|
||||||
You can also find us on the Polymer Slack in the [#open-wc](https://polymer.slack.com/archives/CE6D9DN05) channel.
|
|
||||||
|
|
||||||
You can join the Polymer Slack by visiting [https://www.polymer-project.org/slack-invite](https://www.polymer-project.org/slack-invite).
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
```js server
|
|
||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = 'about/sponsor.rocket.md';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu, layout } from '../recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu, layout };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
```
|
|
||||||
|
|
||||||
# Sponsor
|
|
||||||
|
|
||||||
We currently can only accept sponsoring in the form of services or contributions.
|
|
||||||
|
|
||||||
If you are interested in monetary sponsoring please [let us know](mailto:hello@modern-web.dev).
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = 'index.rocket.js';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu } from './recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
|
|
||||||
import { html } from 'lit-html';
|
|
||||||
|
|
||||||
import { LayoutHome } from '@rocket/launch';
|
|
||||||
|
|
||||||
export const layout = new LayoutHome({
|
|
||||||
pageTree,
|
|
||||||
footerMenu,
|
|
||||||
slogan: 'The modern web setup for static sites with a sprinkle of JavaScript.',
|
|
||||||
callToActionItems: [
|
|
||||||
{ text: 'Follow Guides', href: '/guides/' },
|
|
||||||
{ text: 'Browse Docs', href: '/docs/' },
|
|
||||||
],
|
|
||||||
background: '/home-background.svg',
|
|
||||||
reasonHeader: 'Why Rocket?',
|
|
||||||
reasons: [
|
|
||||||
{
|
|
||||||
header: 'Small',
|
|
||||||
text:
|
|
||||||
'No overblown tools or frontend frameworks, add JavaScript and/or Web Components only on pages where needed.',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
header: 'Pre-Rendered',
|
|
||||||
text: 'Statically generated content means less JavaScript to ship and process.',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
header: 'Zero Configuration',
|
|
||||||
text: 'Automatic code splitting, filesystem based routing, and JavaScript in Markdown.',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
header: 'Meta Framework',
|
|
||||||
text: html`Build on top of giants like <a href="https://www.11ty.dev/">Eleventy</a>,
|
|
||||||
<a href="https://rollupjs.org/">Rollup</a>, and
|
|
||||||
<a href="https://www.modern-web.dev/">Modern Web</a>.`,
|
|
||||||
},
|
|
||||||
{ header: 'Powerful Default Template', text: 'Provide content and you are ready to go.' },
|
|
||||||
{
|
|
||||||
header: 'Ready for Production',
|
|
||||||
text:
|
|
||||||
'Optimized for a smaller build size, faster dev compilation and dozens of other improvements.',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
export default () => '';
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
import { PageTree } from '@rocket/engine';
|
|
||||||
import { LayoutSidebar } from '@rocket/launch';
|
|
||||||
import { adjustPluginOptions } from 'plugins-manager';
|
|
||||||
import { mdjsSetupCode } from '@mdjs/core';
|
|
||||||
|
|
||||||
export const pageTree = new PageTree({
|
|
||||||
inputDir: new URL('./', import.meta.url),
|
|
||||||
outputDir: new URL('../_site', import.meta.url),
|
|
||||||
});
|
|
||||||
await pageTree.restore();
|
|
||||||
|
|
||||||
export const setupUnifiedPlugins = [
|
|
||||||
adjustPluginOptions(mdjsSetupCode, {
|
|
||||||
simulationSettings: {
|
|
||||||
simulatorUrl: '/simulator/',
|
|
||||||
themes: [
|
|
||||||
{ key: 'light', name: 'Light' },
|
|
||||||
{ key: 'dark', name: 'Dark' },
|
|
||||||
],
|
|
||||||
platforms: [
|
|
||||||
{ key: 'web', name: 'Web' },
|
|
||||||
{ key: 'android', name: 'Android' },
|
|
||||||
{ key: 'ios', name: 'iOS' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
|
|
||||||
export const footerMenu = [
|
|
||||||
{
|
|
||||||
name: 'Discover',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
text: 'Blog',
|
|
||||||
href: '/blog/',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Help and Feedback',
|
|
||||||
href: 'https://github.com/modernweb-dev/rocket/issues',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Follow',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
text: 'GitHub',
|
|
||||||
href: 'https://github.com/modernweb-dev/rocket',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Twitter',
|
|
||||||
href: 'https://twitter.com/modern_web_dev',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Slack',
|
|
||||||
href: '/about/slack/',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Support',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
text: 'Sponsor',
|
|
||||||
href: '/about/sponsor/',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Contribute',
|
|
||||||
href: 'https://github.com/modernweb-dev/rocket/blob/main/CONTRIBUTING.md',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const layout = new LayoutSidebar({ pageTree, footerMenu });
|
|
||||||
|
|
||||||
// export const openGraphLayout = new OpenGraphLayoutLogo();
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
/* START - Rocket auto generated - do not touch */
|
|
||||||
export const sourceRelativeFilePath = 'sitemap.xml.rocket.js';
|
|
||||||
import { pageTree, setupUnifiedPlugins, footerMenu } from './recursive.data.js';
|
|
||||||
export { pageTree, setupUnifiedPlugins, footerMenu };
|
|
||||||
/* END - Rocket auto generated - do not touch */
|
|
||||||
|
|
||||||
export const layout = false;
|
|
||||||
|
|
||||||
import rocketConfig from '../rocket.config.js';
|
|
||||||
|
|
||||||
export default () => `<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
||||||
|
|
||||||
${pageTree.all().map(
|
|
||||||
page => `
|
|
||||||
<url>
|
|
||||||
<loc>${rocketConfig.absoluteBaseUrl}${page.model.url}</loc>
|
|
||||||
<lastmod>${new Date().toISOString()}</lastmod>
|
|
||||||
<changefreq>monthly</changefreq>
|
|
||||||
</url>
|
|
||||||
`,
|
|
||||||
)}
|
|
||||||
|
|
||||||
</urlset>
|
|
||||||
`;
|
|
||||||
@@ -15,5 +15,8 @@ yarn-error.log*
|
|||||||
|
|
||||||
# Rocket ignore files
|
# Rocket ignore files
|
||||||
*-mdjs-generated.js
|
*-mdjs-generated.js
|
||||||
|
*-converted-html.js
|
||||||
|
*-converted-md.js
|
||||||
|
*-converted-md-source.js
|
||||||
_site
|
_site
|
||||||
_site-dev
|
_site-dev
|
||||||
44
examples/01-hydration-starter/README.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Rocket Starter Kit: Minimal
|
||||||
|
|
||||||
|
```
|
||||||
|
npx @rocket/create@latest --template 01-hydration-starter
|
||||||
|
```
|
||||||
|
|
||||||
|
> 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun!
|
||||||
|
|
||||||
|
## 🚀 Project Structure
|
||||||
|
|
||||||
|
Inside of your Rocket project, you'll see the following folders and files:
|
||||||
|
|
||||||
|
```
|
||||||
|
.
|
||||||
|
├── config
|
||||||
|
│ └── rocket.config.js
|
||||||
|
├── site
|
||||||
|
│ ├── pages
|
||||||
|
│ │ └── index.rocket.html
|
||||||
|
│ └── public
|
||||||
|
│ └── favicon.ico
|
||||||
|
└── package.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Rocket looks for `.rocket.md` or `.rocket.js` or `.rocket.html` files in the `site/pages` directory. Each page is exposed as a route based on its file name.
|
||||||
|
|
||||||
|
There's nothing special about `site/src/components/`, but that's where we like to put our web components.
|
||||||
|
|
||||||
|
Any static assets, that is not referenced via HTML but you still want to be on the web server we can place in the `site/public/` directory.
|
||||||
|
|
||||||
|
## 🧞 Commands
|
||||||
|
|
||||||
|
All commands are run from the root of the project, from a terminal:
|
||||||
|
|
||||||
|
| Command | Action |
|
||||||
|
| :---------------- | :------------------------------------------- |
|
||||||
|
| `npm install` | Installs dependencies |
|
||||||
|
| `npm run start` | Starts local dev server at `localhost:8000` |
|
||||||
|
| `npm run build` | Build your production site to `./_site/` |
|
||||||
|
| `npm run preview` | Preview your build locally, before deploying |
|
||||||
|
|
||||||
|
## 👀 Want to learn more?
|
||||||
|
|
||||||
|
Feel free to check [our documentation](https://rocket.modern-web.dev) or jump into our [Discord server](https://rocket.modern-web.dev/chat).
|
||||||
23
examples/01-hydration-starter/package.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"name": "rocket-hydration-starter",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"private": true,
|
||||||
|
"description": "Example on how to hydrate web components",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"build": "rocket build",
|
||||||
|
"dev": "npm start",
|
||||||
|
"preview": "rocket preview --open",
|
||||||
|
"start": "NODE_DEBUG=engine:rendering rocket start --open"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@rocket/cli": "^0.20.0",
|
||||||
|
"@rocket/engine": "^0.2.0",
|
||||||
|
"@webcomponents/template-shadowroot": "^0.1.0",
|
||||||
|
"lit": "^2.3.0"
|
||||||
|
},
|
||||||
|
"@rocket/template-name": "Hydration Starter",
|
||||||
|
"imports": {
|
||||||
|
"#components/*": "./site/src/components/*"
|
||||||
|
}
|
||||||
|
}
|
||||||
34
examples/01-hydration-starter/site/pages/index.rocket.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/* START - Rocket auto generated - do not touch */
|
||||||
|
export const sourceRelativeFilePath = 'index.rocket.js';
|
||||||
|
import { html, components, layout } from './recursive.data.js';
|
||||||
|
export { html, components, layout };
|
||||||
|
export async function registerCustomElements() {
|
||||||
|
// server-only components
|
||||||
|
customElements.define(
|
||||||
|
'hello-wave',
|
||||||
|
await import('#components/HelloWave.js').then(m => m.HelloWave),
|
||||||
|
);
|
||||||
|
// hydrate-able components
|
||||||
|
customElements.define(
|
||||||
|
'hello-typer',
|
||||||
|
await import('#components/HelloTyper.js').then(m => m.HelloTyper),
|
||||||
|
);
|
||||||
|
customElements.define(
|
||||||
|
'my-counter',
|
||||||
|
await import('#components/MyCounter.js').then(m => m.MyCounter),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export const needsLoader = true;
|
||||||
|
/* END - Rocket auto generated - do not touch */
|
||||||
|
|
||||||
|
export default () => html`
|
||||||
|
<h1>Hello World</h1>
|
||||||
|
<hello-wave></hello-wave>
|
||||||
|
<hello-typer loading="hydrate:onVisible"></hello-typer>
|
||||||
|
<details open>
|
||||||
|
<!-- put an open attribute on the details element to check hydration as you scroll down -->
|
||||||
|
<summary>👇</summary>
|
||||||
|
<p style="height: 120vh;">Emptiness of space</p>
|
||||||
|
</details>
|
||||||
|
<my-counter loading="hydrate:onVisible"></my-counter>
|
||||||
|
`;
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"h1": "Hello World",
|
||||||
|
"name": "Hello World",
|
||||||
|
"menuLinkText": "Hello World",
|
||||||
|
"url": "/",
|
||||||
|
"outputRelativeFilePath": "index.html",
|
||||||
|
"sourceRelativeFilePath": "index.rocket.js",
|
||||||
|
"level": 0,
|
||||||
|
"components": {
|
||||||
|
"hello-wave": "#components/HelloWave.js::HelloWave",
|
||||||
|
"hello-typer": "#components/HelloTyper.js::HelloTyper",
|
||||||
|
"my-counter": "#components/MyCounter.js::MyCounter"
|
||||||
|
},
|
||||||
|
"needsLoader": true
|
||||||
|
}
|
||||||
24
examples/01-hydration-starter/site/pages/recursive.data.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { html } from 'lit';
|
||||||
|
|
||||||
|
export { html };
|
||||||
|
|
||||||
|
export const components = {
|
||||||
|
'hello-wave': '#components/HelloWave.js::HelloWave',
|
||||||
|
'hello-typer': '#components/HelloTyper.js::HelloTyper',
|
||||||
|
'my-counter': '#components/MyCounter.js::MyCounter',
|
||||||
|
// 👆 we are using a private import defined in the package json that maps
|
||||||
|
// "#components/*": "./site/src/components/*"
|
||||||
|
// (see https://nodejs.org/api/packages.html#packages_imports)
|
||||||
|
};
|
||||||
|
|
||||||
|
export const layout = data => html`
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
${data.content()}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`;
|
||||||
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 69 KiB |
BIN
examples/01-hydration-starter/site/public/apple-touch-icon.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
examples/01-hydration-starter/site/public/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
12
examples/01-hydration-starter/site/public/icon.svg
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<svg width="105" height="101" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="m19.91 91.438 12.445-4.705-8.09-7.465-4.355 12.17Z" fill="#FCB736"/>
|
||||||
|
<path d="M53.778 41.196c-1.6-5.176 1.444-10.652 6.844-12.192 5.378-1.54 11.067 1.39 12.667 6.588a9.426 9.426 0 0 1 .277 4.512 9.595 9.595 0 0 1-1.86 4.151 10.076 10.076 0 0 1-3.6 2.902 10.485 10.485 0 0 1-4.573 1.033c-4.4 0-8.444-2.738-9.755-6.994ZM68.666 16.62c-9.066 2.952-19.088 8.085-27.022 16.042-6.4 6.416-11.311 12.47-15 17.71a28.068 28.068 0 0 0-3.889.32A23.592 23.592 0 0 0 18.6 51.72C9.533 54.928-.49 63.42.133 65.11c.6 1.69 6.467-1.433 11.467-1.818 2.91-.236 5.178.042 6.91.492-.577 1.154-1.066 2.138-1.421 2.93-.378.791-.645 1.369-.823 1.732l18.09 16.705c.733-.385 2.377-1.112 4.733-2.353.266.813.51 1.776.644 2.866.156 1.091.222 2.332.156 3.743-.2 4.813-3.2 10.588-1.423 11.101 1.778.514 10.178-9.475 13.134-18.33.91-2.695 1.133-5.433 1.066-7.786 5.29-3.785 11.356-8.726 17.756-15.164 7.933-7.957 12.844-17.796 15.533-26.65 2.356-7.765 2.978-14.738 2.4-19.037a22.605 22.605 0 0 0-2.155-.085c-4.511-.022-10.756.962-17.534 3.165Z" fill="url(#a)"/>
|
||||||
|
<path d="m12.4 89.535 15.911-6.545-9.777-9.026-6.134 15.57Z" fill="#D08A06"/>
|
||||||
|
<path d="m10.488 82.733 12.467-4.684-8.089-7.465-4.378 12.149ZM90.644 16.406c.044 2.823-.267 6.096-.912 9.54 7.712 10.544 10.889 24.083 7.578 37.623-5.778 23.591-29.178 38.756-53.622 35.612-.133.15-.267.278-.4.428 27.045 4.834 53.556-11.614 59.911-37.666 4.111-16.897-1.155-33.752-12.555-45.537ZM2.82 42.158C8.955 17.048 35.088 1.477 61.177 7.401c5 1.134 9.644 2.973 13.822 5.39 3.6-.791 7.067-1.262 10.067-1.347-5.822-4.492-12.756-7.828-20.511-9.582C36.665-4.47 8.733 12.172 2.177 39.014a47.973 47.973 0 0 0-.511 20.619c.111-.107.222-.193.333-.3-.8-5.56-.6-11.378.822-17.175Z" fill="#FCB736"/>
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="a" x1="26.5" y1="57" x2="89" y2="13" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#D21B1D"/>
|
||||||
|
<stop offset="1" stop-color="#C9181A"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.0 KiB |
19
examples/01-hydration-starter/site/public/site.webmanifest
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "Rocket",
|
||||||
|
"short_name": "Rocket",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "/android-chrome-192x192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/android-chrome-512x512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"theme_color": "#ffffff",
|
||||||
|
"background_color": "#ffffff",
|
||||||
|
"display": "standalone"
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { LitElement, html, css } from 'lit';
|
||||||
|
|
||||||
|
let i = 0;
|
||||||
|
const fullText = [...'to this wonderful world of progressive hydration 🤯'];
|
||||||
|
|
||||||
|
export class HelloTyper extends LitElement {
|
||||||
|
static properties = {
|
||||||
|
msg: { type: String },
|
||||||
|
counter: { type: Number },
|
||||||
|
};
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.msg = ' ';
|
||||||
|
this.counter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
updated(changedProperties) {
|
||||||
|
super.updated(changedProperties);
|
||||||
|
if (i < fullText.length) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.msg += fullText[i];
|
||||||
|
i += 1;
|
||||||
|
}, Math.floor(Math.random() * 50) + 40);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return html`
|
||||||
|
<p>🤔 Hello <span>${this.msg}</span>${'🤯'.repeat(this.counter)}</p>
|
||||||
|
<button @click=${this._inc}>+</button>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
_inc() {
|
||||||
|
if (i >= fullText.length) {
|
||||||
|
this.counter += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static styles = [
|
||||||
|
css`
|
||||||
|
button {
|
||||||
|
font-size: 200%;
|
||||||
|
width: 64px;
|
||||||
|
height: 64px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 10px;
|
||||||
|
background-color: seagreen;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { LitElement, html, css } from 'lit';
|
||||||
|
|
||||||
|
export class HelloWave extends LitElement {
|
||||||
|
render() {
|
||||||
|
return html`<h2>Hello 👋</h2>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static styles = css`
|
||||||
|
h2 {
|
||||||
|
color: #e03131;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { LitElement, css, html } from 'lit';
|
||||||
|
|
||||||
|
export class MyCounter extends LitElement {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.counter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return html`
|
||||||
|
<button @click=${() => (this.counter -= 1)}>-</button>
|
||||||
|
<span>${this.counter}</span>
|
||||||
|
<button @click=${() => (this.counter += 1)}>+</button>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static styles = css`
|
||||||
|
* {
|
||||||
|
font-size: 200%;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
width: 4rem;
|
||||||
|
display: inline-block;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
width: 64px;
|
||||||
|
height: 64px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 10px;
|
||||||
|
background-color: seagreen;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
static properties = {
|
||||||
|
counter: { type: Number },
|
||||||
|
};
|
||||||
|
}
|
||||||
7
examples/01-hydration-starter/tsconfig.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"allowJs": true,
|
||||||
|
"checkJs": false,
|
||||||
|
}
|
||||||
|
}
|
||||||
22
examples/02-blog-starter/.gitignore
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# dependencies
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# logs
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
|
||||||
|
# environment variables
|
||||||
|
.env
|
||||||
|
.env.production
|
||||||
|
|
||||||
|
# macOS-specific files
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Rocket ignore files
|
||||||
|
*-mdjs-generated.js
|
||||||
|
*-converted-html.js
|
||||||
|
*-converted-md.js
|
||||||
|
*-converted-md-source.js
|
||||||
|
_site
|
||||||
|
_site-dev
|
||||||
44
examples/02-blog-starter/README.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Rocket Starter Kit: Blog
|
||||||
|
|
||||||
|
```
|
||||||
|
npx @rocket/create@latest --template 02-blog-starter
|
||||||
|
```
|
||||||
|
|
||||||
|
> 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun!
|
||||||
|
|
||||||
|
## 🚀 Project Structure
|
||||||
|
|
||||||
|
Inside of your Rocket project, you'll see the following folders and files:
|
||||||
|
|
||||||
|
```
|
||||||
|
.
|
||||||
|
├── config
|
||||||
|
│ └── rocket.config.js
|
||||||
|
├── site
|
||||||
|
│ ├── pages
|
||||||
|
│ │ └── index.rocket.html
|
||||||
|
│ └── public
|
||||||
|
│ └── favicon.ico
|
||||||
|
└── package.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Rocket looks for `.rocket.md` or `.rocket.js` or `.rocket.html` files in the `site/pages` directory. Each page is exposed as a route based on its file name.
|
||||||
|
|
||||||
|
There's nothing special about `site/src/components/`, but that's where we like to put our web components.
|
||||||
|
|
||||||
|
Any static assets, that is not referenced via HTML but you still want to be on the web server we can place in the `site/public/` directory.
|
||||||
|
|
||||||
|
## 🧞 Commands
|
||||||
|
|
||||||
|
All commands are run from the root of the project, from a terminal:
|
||||||
|
|
||||||
|
| Command | Action |
|
||||||
|
| :---------------- | :------------------------------------------- |
|
||||||
|
| `npm install` | Installs dependencies |
|
||||||
|
| `npm run start` | Starts local dev server at `localhost:8000` |
|
||||||
|
| `npm run build` | Build your production site to `./_site/` |
|
||||||
|
| `npm run preview` | Preview your build locally, before deploying |
|
||||||
|
|
||||||
|
## 👀 Want to learn more?
|
||||||
|
|
||||||
|
Feel free to check [our documentation](https://rocket.modern-web.dev) or jump into our [Discord server](https://rocket.modern-web.dev/chat).
|
||||||
5
examples/02-blog-starter/config/rocket.config.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
export default /** @type {import('@rocket/cli').RocketCliOptions} */ ({
|
||||||
|
absoluteBaseUrl: 'http://localhost:8080',
|
||||||
|
longFileHeaderWidth: 100,
|
||||||
|
longFileHeaderComment: '// prettier-ignore',
|
||||||
|
});
|
||||||
24
examples/02-blog-starter/package.json
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "rocket-blog-starter",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"private": true,
|
||||||
|
"description": "Get started with a new blog",
|
||||||
|
"type": "module",
|
||||||
|
"exports": {
|
||||||
|
".": "./src/index.js",
|
||||||
|
"./styles/*": "./site/src/styles/*",
|
||||||
|
"./components/*": "./site/src/components/*.js"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "rocket build",
|
||||||
|
"dev": "npm start",
|
||||||
|
"preview": "rocket preview --open",
|
||||||
|
"start": "NODE_DEBUG=engine:rendering rocket start --open"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@rocket/cli": "^0.20.0",
|
||||||
|
"@rocket/engine": "^0.2.0",
|
||||||
|
"lit": "^2.3.0"
|
||||||
|
},
|
||||||
|
"@rocket/template-name": "Blog Starter"
|
||||||
|
}
|
||||||
18
examples/02-blog-starter/site/pages/about.rocket.md
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
```js server
|
||||||
|
/* START - Rocket auto generated - do not touch */
|
||||||
|
export const sourceRelativeFilePath = 'about.rocket.md';
|
||||||
|
import { html, layout, components } from './recursive.data.js';
|
||||||
|
export { html, layout, components };
|
||||||
|
export async function registerCustomElements() {
|
||||||
|
// server-only components
|
||||||
|
// prettier-ignore
|
||||||
|
customElements.define('blog-header', await import('rocket-blog-starter/components/BlogHeader').then(m => m.BlogHeader));
|
||||||
|
// prettier-ignore
|
||||||
|
customElements.define('site-footer', await import('rocket-blog-starter/components/SiteFooter').then(m => m.SiteFooter));
|
||||||
|
}
|
||||||
|
/* END - Rocket auto generated - do not touch */
|
||||||
|
```
|
||||||
|
|
||||||
|
# About
|
||||||
|
|
||||||
|
I love writing about things.
|
||||||
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.8 MiB |
@@ -0,0 +1,42 @@
|
|||||||
|
```js server
|
||||||
|
/* START - Rocket auto generated - do not touch */
|
||||||
|
export const sourceRelativeFilePath = 'blog/hello-world.rocket.md';
|
||||||
|
import { html, components } from '../recursive.data.js';
|
||||||
|
import { layout } from './local.data.js';
|
||||||
|
export { html, layout, components };
|
||||||
|
export async function registerCustomElements() {
|
||||||
|
// server-only components
|
||||||
|
// prettier-ignore
|
||||||
|
customElements.define('blog-header', await import('rocket-blog-starter/components/BlogHeader').then(m => m.BlogHeader));
|
||||||
|
// prettier-ignore
|
||||||
|
customElements.define('blog-author', await import('rocket-blog-starter/components/BlogAuthor').then(m => m.BlogAuthor));
|
||||||
|
// prettier-ignore
|
||||||
|
customElements.define('blog-post', await import('rocket-blog-starter/components/BlogPost').then(m => m.BlogPost));
|
||||||
|
// prettier-ignore
|
||||||
|
customElements.define('site-footer', await import('rocket-blog-starter/components/SiteFooter').then(m => m.SiteFooter));
|
||||||
|
}
|
||||||
|
/* END - Rocket auto generated - do not touch */
|
||||||
|
|
||||||
|
export const title = 'Hello world!';
|
||||||
|
export const publishDate = '12 Sep 2021';
|
||||||
|
export const author = 'Thomas Allmer (@daKmoR)';
|
||||||
|
export const authorHref = 'https://twitter.com/daKmoR';
|
||||||
|
export const value = 128;
|
||||||
|
export const description = 'Just a Hello World Post!';
|
||||||
|
```
|
||||||
|
|
||||||
|
hey
|
||||||
|
|
||||||
|
This is so cool!
|
||||||
|
|
||||||
|
Do variables work ${value \* 2}?
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
There are multiple Co-Authors:
|
||||||
|
|
||||||
|
- <blog-author name="Another Author" href="https://twitter.com/daKmoR"></blog-author>
|
||||||
9
examples/02-blog-starter/site/pages/blog/index.rocket.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
/* START - Rocket auto generated - do not touch */
|
||||||
|
export const sourceRelativeFilePath = 'blog/index.rocket.js';
|
||||||
|
import { html, components } from '../recursive.data.js';
|
||||||
|
export { html, components };
|
||||||
|
/* END - Rocket auto generated - do not touch */
|
||||||
|
|
||||||
|
export const layout = false;
|
||||||
|
|
||||||
|
export default () => 'posts';
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
```js server
|
||||||
|
/* START - Rocket auto generated - do not touch */
|
||||||
|
export const sourceRelativeFilePath = 'blog/with-image.rocket.md';
|
||||||
|
import { html, components } from '../recursive.data.js';
|
||||||
|
import { layout } from './local.data.js';
|
||||||
|
export { html, layout, components };
|
||||||
|
export async function registerCustomElements() {
|
||||||
|
// server-only components
|
||||||
|
// prettier-ignore
|
||||||
|
customElements.define('blog-header', await import('rocket-blog-starter/components/BlogHeader').then(m => m.BlogHeader));
|
||||||
|
// prettier-ignore
|
||||||
|
customElements.define('blog-author', await import('rocket-blog-starter/components/BlogAuthor').then(m => m.BlogAuthor));
|
||||||
|
// prettier-ignore
|
||||||
|
customElements.define('blog-post', await import('rocket-blog-starter/components/BlogPost').then(m => m.BlogPost));
|
||||||
|
// prettier-ignore
|
||||||
|
customElements.define('site-footer', await import('rocket-blog-starter/components/SiteFooter').then(m => m.SiteFooter));
|
||||||
|
}
|
||||||
|
/* END - Rocket auto generated - do not touch */
|
||||||
|
|
||||||
|
export const title = 'With Image!';
|
||||||
|
export const publishDate = '13 Sep 2021';
|
||||||
|
export const author = 'Thomas Allmer (@daKmoR)';
|
||||||
|
export const authorHref = 'https://twitter.com/daKmoR';
|
||||||
|
export const value = 128;
|
||||||
|
export const description = 'Now with an image!';
|
||||||
|
export const heroImage = './assets/liftoff-flames.jpg';
|
||||||
|
export const alt = 'Liftoff Flames';
|
||||||
|
```
|
||||||
|
|
||||||
|
hey
|
||||||
|
|
||||||
|
<blog-author name="Another Author" href="https://twitter.com/daKmoR"></blog-author>
|
||||||
|
|
||||||
|
This is so cool!
|
||||||
|
|
||||||
|
Do variables work ${value \* 2}?
|
||||||
@@ -1,24 +1,30 @@
|
|||||||
/* START - Rocket auto generated - do not touch */
|
/* START - Rocket auto generated - do not touch */
|
||||||
export const sourceRelativeFilePath = 'index.rocket.js';
|
export const sourceRelativeFilePath = 'index.rocket.js';
|
||||||
import { html } from './recursive.data.js';
|
import { html, components } from './recursive.data.js';
|
||||||
export { html };
|
export { html, components };
|
||||||
|
export async function registerCustomElements() {
|
||||||
|
// server-only components
|
||||||
|
// prettier-ignore
|
||||||
|
customElements.define('blog-header', await import('rocket-blog-starter/components/BlogHeader').then(m => m.BlogHeader));
|
||||||
|
// prettier-ignore
|
||||||
|
customElements.define('blog-post-preview', await import('rocket-blog-starter/components/BlogPostPreview').then(m => m.BlogPostPreview));
|
||||||
|
// prettier-ignore
|
||||||
|
customElements.define('site-footer', await import('rocket-blog-starter/components/SiteFooter').then(m => m.SiteFooter));
|
||||||
|
}
|
||||||
/* END - Rocket auto generated - do not touch */
|
/* END - Rocket auto generated - do not touch */
|
||||||
|
|
||||||
import { PageTree, nothing } from '@rocket/engine';
|
export const layout = false;
|
||||||
import { baseHead } from '../src/parts/baseHead.js';
|
|
||||||
|
|
||||||
import '../src/components/blog-post-preview.js';
|
import { PageTree } from '@rocket/engine';
|
||||||
import '../src/components/blog-header.js';
|
import { nothing } from 'lit';
|
||||||
|
import { baseHead } from '../src/parts/baseHead.js';
|
||||||
|
|
||||||
export const title = 'Example Blog';
|
export const title = 'Example Blog';
|
||||||
export const description = 'The perfect starter for your perfect blog.';
|
export const description = 'The perfect starter for your perfect blog.';
|
||||||
export const permalink = 'https://example.com/';
|
export const permalink = 'https://example.com/';
|
||||||
|
|
||||||
export const pageTree = new PageTree({
|
export const pageTree = new PageTree();
|
||||||
inputDir: new URL('./', import.meta.url),
|
await pageTree.restore(new URL('./pageTreeData.rocketGenerated.json', import.meta.url));
|
||||||
outputDir: new URL('../_site', import.meta.url),
|
|
||||||
});
|
|
||||||
await pageTree.restore();
|
|
||||||
|
|
||||||
class BlogMenu {
|
class BlogMenu {
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +46,6 @@ class BlogMenu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default () => html`
|
export default () => html`
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
@@ -90,10 +95,11 @@ export default () => html`
|
|||||||
<p>${description}</p>
|
<p>${description}</p>
|
||||||
</section>
|
</section>
|
||||||
<section aria-label="Blog post list">
|
<section aria-label="Blog post list">
|
||||||
${pageTree.renderMenu(new BlogMenu(), 'posts/index.rocket.js')}
|
${pageTree.renderMenu(new BlogMenu(), 'blog/index.rocket.js')}
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
<site-footer></site-footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
{
|
||||||
|
"title": "Example Blog",
|
||||||
|
"h1": "My Blog",
|
||||||
|
"name": "Example Blog",
|
||||||
|
"menuLinkText": "My Blog",
|
||||||
|
"url": "/",
|
||||||
|
"outputRelativeFilePath": "index.html",
|
||||||
|
"sourceRelativeFilePath": "index.rocket.js",
|
||||||
|
"level": 0,
|
||||||
|
"components": {
|
||||||
|
"blog-author": "rocket-blog-starter/components/BlogAuthor::BlogAuthor",
|
||||||
|
"blog-header": "rocket-blog-starter/components/BlogHeader::BlogHeader",
|
||||||
|
"blog-post": "rocket-blog-starter/components/BlogPost::BlogPost",
|
||||||
|
"blog-post-preview": "rocket-blog-starter/components/BlogPostPreview::BlogPostPreview",
|
||||||
|
"site-footer": "rocket-blog-starter/components/SiteFooter::SiteFooter"
|
||||||
|
},
|
||||||
|
"description": "The perfect starter for your perfect blog.",
|
||||||
|
"layout": false,
|
||||||
|
"permalink": "https://example.com/",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"title": "",
|
||||||
|
"h1": "My Blog",
|
||||||
|
"headlinesWithId": [
|
||||||
|
{
|
||||||
|
"text": "About",
|
||||||
|
"id": "about",
|
||||||
|
"level": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "My Blog",
|
||||||
|
"menuLinkText": "My Blog",
|
||||||
|
"url": "/about/",
|
||||||
|
"outputRelativeFilePath": "about/index.html",
|
||||||
|
"sourceRelativeFilePath": "about.rocket.md",
|
||||||
|
"level": 1,
|
||||||
|
"components": {
|
||||||
|
"blog-author": "rocket-blog-starter/components/BlogAuthor::BlogAuthor",
|
||||||
|
"blog-header": "rocket-blog-starter/components/BlogHeader::BlogHeader",
|
||||||
|
"blog-post": "rocket-blog-starter/components/BlogPost::BlogPost",
|
||||||
|
"blog-post-preview": "rocket-blog-starter/components/BlogPostPreview::BlogPostPreview",
|
||||||
|
"site-footer": "rocket-blog-starter/components/SiteFooter::SiteFooter"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "blog/index.rocket.js",
|
||||||
|
"menuLinkText": "blog/index.rocket.js",
|
||||||
|
"url": "/blog/",
|
||||||
|
"outputRelativeFilePath": "blog/index.html",
|
||||||
|
"sourceRelativeFilePath": "blog/index.rocket.js",
|
||||||
|
"level": 1,
|
||||||
|
"components": {
|
||||||
|
"blog-author": "rocket-blog-starter/components/BlogAuthor::BlogAuthor",
|
||||||
|
"blog-header": "rocket-blog-starter/components/BlogHeader::BlogHeader",
|
||||||
|
"blog-post": "rocket-blog-starter/components/BlogPost::BlogPost",
|
||||||
|
"blog-post-preview": "rocket-blog-starter/components/BlogPostPreview::BlogPostPreview",
|
||||||
|
"site-footer": "rocket-blog-starter/components/SiteFooter::SiteFooter"
|
||||||
|
},
|
||||||
|
"layout": false,
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"title": "Hello world!",
|
||||||
|
"h1": "My Blog",
|
||||||
|
"name": "Hello world!",
|
||||||
|
"menuLinkText": "My Blog",
|
||||||
|
"url": "/blog/hello-world/",
|
||||||
|
"outputRelativeFilePath": "blog/hello-world/index.html",
|
||||||
|
"sourceRelativeFilePath": "blog/hello-world.rocket.md",
|
||||||
|
"level": 2,
|
||||||
|
"author": "Thomas Allmer (@daKmoR)",
|
||||||
|
"authorHref": "https://twitter.com/daKmoR",
|
||||||
|
"components": {
|
||||||
|
"blog-author": "rocket-blog-starter/components/BlogAuthor::BlogAuthor",
|
||||||
|
"blog-header": "rocket-blog-starter/components/BlogHeader::BlogHeader",
|
||||||
|
"blog-post": "rocket-blog-starter/components/BlogPost::BlogPost",
|
||||||
|
"blog-post-preview": "rocket-blog-starter/components/BlogPostPreview::BlogPostPreview",
|
||||||
|
"site-footer": "rocket-blog-starter/components/SiteFooter::SiteFooter"
|
||||||
|
},
|
||||||
|
"description": "Just a Hello World Post!",
|
||||||
|
"publishDate": "12 Sep 2021",
|
||||||
|
"value": 128
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "With Image!",
|
||||||
|
"h1": "My Blog",
|
||||||
|
"name": "With Image!",
|
||||||
|
"menuLinkText": "My Blog",
|
||||||
|
"url": "/blog/with-image/",
|
||||||
|
"outputRelativeFilePath": "blog/with-image/index.html",
|
||||||
|
"sourceRelativeFilePath": "blog/with-image.rocket.md",
|
||||||
|
"level": 2,
|
||||||
|
"alt": "Liftoff Flames",
|
||||||
|
"author": "Thomas Allmer (@daKmoR)",
|
||||||
|
"authorHref": "https://twitter.com/daKmoR",
|
||||||
|
"components": {
|
||||||
|
"blog-author": "rocket-blog-starter/components/BlogAuthor::BlogAuthor",
|
||||||
|
"blog-header": "rocket-blog-starter/components/BlogHeader::BlogHeader",
|
||||||
|
"blog-post": "rocket-blog-starter/components/BlogPost::BlogPost",
|
||||||
|
"blog-post-preview": "rocket-blog-starter/components/BlogPostPreview::BlogPostPreview",
|
||||||
|
"site-footer": "rocket-blog-starter/components/SiteFooter::SiteFooter"
|
||||||
|
},
|
||||||
|
"description": "Now with an image!",
|
||||||
|
"heroImage": "./assets/liftoff-flames.jpg",
|
||||||
|
"publishDate": "13 Sep 2021",
|
||||||
|
"value": 128
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
15
examples/02-blog-starter/site/pages/recursive.data.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
// everything you export here will be automatically injected into all pages
|
||||||
|
|
||||||
|
import { LayoutPage } from '../src/layouts/LayoutPage.js';
|
||||||
|
|
||||||
|
export { html } from 'lit';
|
||||||
|
|
||||||
|
export const layout = new LayoutPage();
|
||||||
|
|
||||||
|
export const components = {
|
||||||
|
'blog-author': 'rocket-blog-starter/components/BlogAuthor::BlogAuthor',
|
||||||
|
'blog-header': 'rocket-blog-starter/components/BlogHeader::BlogHeader',
|
||||||
|
'blog-post': 'rocket-blog-starter/components/BlogPost::BlogPost',
|
||||||
|
'blog-post-preview': 'rocket-blog-starter/components/BlogPostPreview::BlogPostPreview',
|
||||||
|
'site-footer': 'rocket-blog-starter/components/SiteFooter::SiteFooter',
|
||||||
|
};
|
||||||
BIN
examples/02-blog-starter/site/public/android-chrome-192x192.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
examples/02-blog-starter/site/public/android-chrome-512x512.png
Normal file
|
After Width: | Height: | Size: 69 KiB |
BIN
examples/02-blog-starter/site/public/apple-touch-icon.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
examples/02-blog-starter/site/public/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
12
examples/02-blog-starter/site/public/icon.svg
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<svg width="105" height="101" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="m19.91 91.438 12.445-4.705-8.09-7.465-4.355 12.17Z" fill="#FCB736"/>
|
||||||
|
<path d="M53.778 41.196c-1.6-5.176 1.444-10.652 6.844-12.192 5.378-1.54 11.067 1.39 12.667 6.588a9.426 9.426 0 0 1 .277 4.512 9.595 9.595 0 0 1-1.86 4.151 10.076 10.076 0 0 1-3.6 2.902 10.485 10.485 0 0 1-4.573 1.033c-4.4 0-8.444-2.738-9.755-6.994ZM68.666 16.62c-9.066 2.952-19.088 8.085-27.022 16.042-6.4 6.416-11.311 12.47-15 17.71a28.068 28.068 0 0 0-3.889.32A23.592 23.592 0 0 0 18.6 51.72C9.533 54.928-.49 63.42.133 65.11c.6 1.69 6.467-1.433 11.467-1.818 2.91-.236 5.178.042 6.91.492-.577 1.154-1.066 2.138-1.421 2.93-.378.791-.645 1.369-.823 1.732l18.09 16.705c.733-.385 2.377-1.112 4.733-2.353.266.813.51 1.776.644 2.866.156 1.091.222 2.332.156 3.743-.2 4.813-3.2 10.588-1.423 11.101 1.778.514 10.178-9.475 13.134-18.33.91-2.695 1.133-5.433 1.066-7.786 5.29-3.785 11.356-8.726 17.756-15.164 7.933-7.957 12.844-17.796 15.533-26.65 2.356-7.765 2.978-14.738 2.4-19.037a22.605 22.605 0 0 0-2.155-.085c-4.511-.022-10.756.962-17.534 3.165Z" fill="url(#a)"/>
|
||||||
|
<path d="m12.4 89.535 15.911-6.545-9.777-9.026-6.134 15.57Z" fill="#D08A06"/>
|
||||||
|
<path d="m10.488 82.733 12.467-4.684-8.089-7.465-4.378 12.149ZM90.644 16.406c.044 2.823-.267 6.096-.912 9.54 7.712 10.544 10.889 24.083 7.578 37.623-5.778 23.591-29.178 38.756-53.622 35.612-.133.15-.267.278-.4.428 27.045 4.834 53.556-11.614 59.911-37.666 4.111-16.897-1.155-33.752-12.555-45.537ZM2.82 42.158C8.955 17.048 35.088 1.477 61.177 7.401c5 1.134 9.644 2.973 13.822 5.39 3.6-.791 7.067-1.262 10.067-1.347-5.822-4.492-12.756-7.828-20.511-9.582C36.665-4.47 8.733 12.172 2.177 39.014a47.973 47.973 0 0 0-.511 20.619c.111-.107.222-.193.333-.3-.8-5.56-.6-11.378.822-17.175Z" fill="#FCB736"/>
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="a" x1="26.5" y1="57" x2="89" y2="13" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#D21B1D"/>
|
||||||
|
<stop offset="1" stop-color="#C9181A"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.0 KiB |
19
examples/02-blog-starter/site/public/site.webmanifest
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "Rocket",
|
||||||
|
"short_name": "Rocket",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "/android-chrome-192x192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/android-chrome-512x512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"theme_color": "#ffffff",
|
||||||
|
"background_color": "#ffffff",
|
||||||
|
"display": "standalone"
|
||||||
|
}
|
||||||
@@ -1,20 +1,24 @@
|
|||||||
import { html, css, LitElement } from 'lit';
|
import { html, css, LitElement } from 'lit';
|
||||||
|
|
||||||
export class BlogAuthor extends LitElement {
|
export class BlogAuthor extends LitElement {
|
||||||
static get properties() {
|
static properties = {
|
||||||
return {
|
name: { type: String },
|
||||||
name: { type: String },
|
href: { type: String },
|
||||||
href: { type: String },
|
};
|
||||||
};
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.name = '';
|
||||||
|
this.href = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
static get styles() {
|
static styles = [
|
||||||
return css`
|
css`
|
||||||
.author {
|
.author {
|
||||||
margin-bottom: 0.75rem;
|
margin-bottom: 0.75rem;
|
||||||
}
|
}
|
||||||
`;
|
`,
|
||||||
}
|
];
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return html`
|
return html`
|
||||||
87
examples/02-blog-starter/site/src/components/BlogHeader.js
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
import { html, css, LitElement } from 'lit';
|
||||||
|
import { shared } from '../styles/shared.js';
|
||||||
|
|
||||||
|
export class BlogHeader extends LitElement {
|
||||||
|
static properties = {
|
||||||
|
name: { type: String },
|
||||||
|
href: { type: String },
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return html`
|
||||||
|
<header class="wrapper">
|
||||||
|
<article>
|
||||||
|
<h1>
|
||||||
|
<a href="/">
|
||||||
|
<img src="resolve:@rocket/engine/assets/logo.svg" class="logo" />
|
||||||
|
<span>My Blog</span>
|
||||||
|
</a>
|
||||||
|
</h1>
|
||||||
|
</article>
|
||||||
|
</header>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static styles = [
|
||||||
|
shared,
|
||||||
|
css`
|
||||||
|
header {
|
||||||
|
padding-top: 1rem;
|
||||||
|
padding-bottom: 1rem;
|
||||||
|
height: 5rem;
|
||||||
|
}
|
||||||
|
article {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
.header-subitem {
|
||||||
|
display: flex;
|
||||||
|
flex-grow: 0;
|
||||||
|
gap: 0.5em;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: var(--theme-text-lighter);
|
||||||
|
font-size: initial;
|
||||||
|
padding: 0.5rem;
|
||||||
|
}
|
||||||
|
.header-subitem:hover {
|
||||||
|
color: var(--theme-accent);
|
||||||
|
}
|
||||||
|
.header-subitem svg {
|
||||||
|
width: 1.5rem;
|
||||||
|
height: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 32em) {
|
||||||
|
.header-subitem {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
max-width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 2.5rem;
|
||||||
|
height: 2.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
margin-left: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 a {
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-flex;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
customElements.define('blog-header', BlogHeader);
|
||||||
@@ -1,16 +1,23 @@
|
|||||||
import { html, css, LitElement } from 'lit';
|
import { html, css, LitElement } from 'lit';
|
||||||
import './blog-author.js';
|
|
||||||
|
|
||||||
export class BlogPost extends LitElement {
|
export class BlogPost extends LitElement {
|
||||||
static get properties() {
|
static properties = {
|
||||||
return {
|
title: { type: String },
|
||||||
title: { type: String },
|
author: { type: String },
|
||||||
author: { type: String },
|
authorHref: { type: String },
|
||||||
authorHref: { type: String },
|
publishDate: { type: String, attribute: 'publish-date' },
|
||||||
publishDate: { type: String, attribute: 'publish-date' },
|
heroImage: { type: String, attribute: 'hero-image' },
|
||||||
heroImage: { type: String, attribute: 'hero-image' },
|
alt: { type: String },
|
||||||
alt: { type: String },
|
};
|
||||||
};
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.title = '';
|
||||||
|
this.author = '';
|
||||||
|
this.authorHref = '';
|
||||||
|
this.publishDate = '';
|
||||||
|
this.heroImage = '';
|
||||||
|
this.alt = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -21,8 +28,8 @@ export class BlogPost extends LitElement {
|
|||||||
<header>
|
<header>
|
||||||
${this.heroImage
|
${this.heroImage
|
||||||
? html`<img
|
? html`<img
|
||||||
width="720"
|
width="600"
|
||||||
height="420"
|
height="400"
|
||||||
class="hero-image"
|
class="hero-image"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
src="${this.heroImage}"
|
src="${this.heroImage}"
|
||||||
@@ -42,8 +49,8 @@ export class BlogPost extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get styles() {
|
static styles = [
|
||||||
return css`
|
css`
|
||||||
.hero-image {
|
.hero-image {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
@@ -100,8 +107,6 @@ export class BlogPost extends LitElement {
|
|||||||
font-size: 2.25rem;
|
font-size: 2.25rem;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
`;
|
`,
|
||||||
}
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define('blog-post', BlogPost);
|
|
||||||
@@ -1,13 +1,20 @@
|
|||||||
import { html, css, LitElement } from 'lit';
|
import { html, css, LitElement, nothing } from 'lit';
|
||||||
|
|
||||||
export class BlogPostPreview extends LitElement {
|
export class BlogPostPreview extends LitElement {
|
||||||
static get properties() {
|
static properties = {
|
||||||
return {
|
post: { type: Object },
|
||||||
post: { type: Object },
|
};
|
||||||
};
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
/** @type {{ publishDate: string; title: string; description: string; url: string; } | undefined} */
|
||||||
|
this.post = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
if (!this.post) {
|
||||||
|
return nothing;
|
||||||
|
}
|
||||||
return html`
|
return html`
|
||||||
<article class="post-preview">
|
<article class="post-preview">
|
||||||
<header>
|
<header>
|
||||||
@@ -20,8 +27,8 @@ export class BlogPostPreview extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get styles() {
|
static styles = [
|
||||||
return css`
|
css`
|
||||||
.content :global(main > * + *) {
|
.content :global(main > * + *) {
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
}
|
}
|
||||||
@@ -58,8 +65,6 @@ export class BlogPostPreview extends LitElement {
|
|||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: var(--theme-text);
|
color: var(--theme-text);
|
||||||
}
|
}
|
||||||
`;
|
`,
|
||||||
}
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define('blog-post-preview', BlogPostPreview);
|
|
||||||
25
examples/02-blog-starter/site/src/components/SiteFooter.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { html, css, LitElement } from 'lit';
|
||||||
|
import { shared } from '../styles/shared.js';
|
||||||
|
|
||||||
|
export class SiteFooter extends LitElement {
|
||||||
|
render() {
|
||||||
|
return html`
|
||||||
|
<footer>
|
||||||
|
<div class="wrapper">
|
||||||
|
<a href="./about.rocket.md">About</a>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static styles = [
|
||||||
|
shared,
|
||||||
|
css`
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
background: #dcdcdc;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
import { html } from '@rocket/engine';
|
import { html } from 'lit';
|
||||||
import { baseHead } from '../parts/baseHead.js';
|
import { baseHead } from '../parts/baseHead.js';
|
||||||
import '../components/blog-header.js';
|
|
||||||
import '../components/blog-post.js';
|
|
||||||
|
|
||||||
export class LayoutBlogPost {
|
export class LayoutBlogPost {
|
||||||
render(data) {
|
render(data) {
|
||||||
const { title, description, publishDate, author, heroImage, permalink, alt, lang } = data;
|
const { title, description, publishDate, author, authorHref, heroImage, permalink, alt, lang } =
|
||||||
|
data;
|
||||||
return html`
|
return html`
|
||||||
<html-server-only lang=${lang || 'en'}>
|
<html-server-only lang=${lang || 'en'}>
|
||||||
<head>
|
<head>
|
||||||
@@ -15,10 +14,18 @@ export class LayoutBlogPost {
|
|||||||
<body>
|
<body>
|
||||||
<blog-header></blog-header>
|
<blog-header></blog-header>
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<blog-post title=${title} author=${author} hero-image=${heroImage} publish-date=${publishDate} alt2=${alt}>
|
<blog-post
|
||||||
|
title=${title}
|
||||||
|
author=${author}
|
||||||
|
.authorHref=${authorHref}
|
||||||
|
hero-image=${heroImage}
|
||||||
|
publish-date=${publishDate}
|
||||||
|
alt=${alt}
|
||||||
|
>
|
||||||
${data.content()}
|
${data.content()}
|
||||||
</blog-post>
|
</blog-post>
|
||||||
</div>
|
</div>
|
||||||
|
<site-footer></site-footer>
|
||||||
</body>
|
</body>
|
||||||
</html-server-only>
|
</html-server-only>
|
||||||
`;
|
`;
|
||||||
63
examples/02-blog-starter/site/src/layouts/LayoutPage.js
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import { html } from 'lit';
|
||||||
|
import { baseHead } from '../parts/baseHead.js';
|
||||||
|
|
||||||
|
export class LayoutPage {
|
||||||
|
render(data) {
|
||||||
|
const { title, description, permalink } = data;
|
||||||
|
return html`
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
${baseHead({ title, description, permalink })}
|
||||||
|
<style>
|
||||||
|
header {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: var(--theme-bg-offset);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
margin-top: 4rem;
|
||||||
|
margin-bottom: 8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content :global(main > * + *) {
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.intro {
|
||||||
|
padding-bottom: 4rem;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
border-bottom: 4px solid var(--theme-divider);
|
||||||
|
}
|
||||||
|
|
||||||
|
.intro > * {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.latest {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<blog-header></blog-header>
|
||||||
|
<div class="wrapper">
|
||||||
|
<main class="content">
|
||||||
|
<section class="intro">
|
||||||
|
<h1 class="latest">${title}</h1>
|
||||||
|
<p>${description}</p>
|
||||||
|
</section>
|
||||||
|
<section aria-label="Blog post list">${data.content()}</section>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
<site-footer></site-footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { html } from '@rocket/engine';
|
import { html } from 'lit';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {{ title: string, description: string, permalink: string }} options
|
* @param {{ title: string, description: string, permalink: string }} options
|
||||||
@@ -21,14 +21,12 @@ export function baseHead({ title, description, permalink }) {
|
|||||||
<meta property="og:url" content="${permalink}" />
|
<meta property="og:url" content="${permalink}" />
|
||||||
<meta property="og:title" content="${title}" />
|
<meta property="og:title" content="${title}" />
|
||||||
<meta property="og:description" content="${description}" />
|
<meta property="og:description" content="${description}" />
|
||||||
<meta property="og:image" content="https://astro.build/social.jpg?v=1" />
|
|
||||||
|
|
||||||
<!-- Twitter -->
|
<!-- Twitter -->
|
||||||
<meta property="twitter:card" content="summary_large_image" />
|
<meta property="twitter:card" content="summary_large_image" />
|
||||||
<meta property="twitter:url" content="${permalink}" />
|
<meta property="twitter:url" content="${permalink}" />
|
||||||
<meta property="twitter:title" content="${title}" />
|
<meta property="twitter:title" content="${title}" />
|
||||||
<meta property="twitter:description" content="${description}" />
|
<meta property="twitter:description" content="${description}" />
|
||||||
<meta property="twitter:image" content="https://astro.build/social.jpg?v=1" />
|
|
||||||
|
|
||||||
<!-- Fonts -->
|
<!-- Fonts -->
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||||
@@ -36,6 +34,6 @@ export function baseHead({ title, description, permalink }) {
|
|||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&family=IBM+Plex+Sans:wght@400;700&display=swap"
|
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&family=IBM+Plex+Sans:wght@400;700&display=swap"
|
||||||
/>
|
/>
|
||||||
<link rel="stylesheet" href="resolve:@example/blog/styles/blog.css" />
|
<link rel="stylesheet" href="resolve:rocket-blog-starter/styles/blog.css" />
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
8
examples/02-blog-starter/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"allowJs": true,
|
||||||
|
"checkJs": false,
|
||||||
|
"module": "esnext"
|
||||||
|
}
|
||||||
|
}
|
||||||
22
examples/03-minimal-starter/.gitignore
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# dependencies
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# logs
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
|
||||||
|
# environment variables
|
||||||
|
.env
|
||||||
|
.env.production
|
||||||
|
|
||||||
|
# macOS-specific files
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Rocket ignore files
|
||||||
|
*-mdjs-generated.js
|
||||||
|
*-converted-html.js
|
||||||
|
*-converted-md.js
|
||||||
|
*-converted-md-source.js
|
||||||
|
_site
|
||||||
|
_site-dev
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
{
|
{
|
||||||
"gitdoc.enabled": false,
|
|
||||||
"typescript.tsdk": "node_modules/typescript/lib",
|
|
||||||
"files.exclude": {
|
"files.exclude": {
|
||||||
"**/*-mdjs-generated.js": true,
|
"**/*-mdjs-generated.js": true,
|
||||||
},
|
},
|
||||||
44
examples/03-minimal-starter/README.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Rocket Starter Kit: Minimal
|
||||||
|
|
||||||
|
```
|
||||||
|
npx @rocket/create@latest --template 03-minimal-starter
|
||||||
|
```
|
||||||
|
|
||||||
|
> 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun!
|
||||||
|
|
||||||
|
## 🚀 Project Structure
|
||||||
|
|
||||||
|
Inside of your Rocket project, you'll see the following folders and files:
|
||||||
|
|
||||||
|
```
|
||||||
|
.
|
||||||
|
├── config
|
||||||
|
│ └── rocket.config.js
|
||||||
|
├── site
|
||||||
|
│ ├── pages
|
||||||
|
│ │ └── index.rocket.html
|
||||||
|
│ └── public
|
||||||
|
│ └── favicon.ico
|
||||||
|
└── package.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Rocket looks for `.rocket.md` or `.rocket.js` or `.rocket.html` files in the `site/pages` directory. Each page is exposed as a route based on its file name.
|
||||||
|
|
||||||
|
There's nothing special about `site/src/components/`, but that's where we like to put our web components.
|
||||||
|
|
||||||
|
Any static assets, that is not referenced via HTML but you still want to be on the web server we can place in the `site/public/` directory.
|
||||||
|
|
||||||
|
## 🧞 Commands
|
||||||
|
|
||||||
|
All commands are run from the root of the project, from a terminal:
|
||||||
|
|
||||||
|
| Command | Action |
|
||||||
|
| :---------------- | :------------------------------------------- |
|
||||||
|
| `npm install` | Installs dependencies |
|
||||||
|
| `npm run start` | Starts local dev server at `localhost:8000` |
|
||||||
|
| `npm run build` | Build your production site to `./_site/` |
|
||||||
|
| `npm run preview` | Preview your build locally, before deploying |
|
||||||
|
|
||||||
|
## 👀 Want to learn more?
|
||||||
|
|
||||||
|
Feel free to check [our documentation](https://rocket.modern-web.dev) or jump into our [Discord server](https://rocket.modern-web.dev/chat).
|
||||||
3
examples/03-minimal-starter/config/rocket.config.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export default /** @type {import('@rocket/cli').RocketCliOptions} */ ({
|
||||||
|
absoluteBaseUrl: 'http://localhost:8080',
|
||||||
|
});
|
||||||
19
examples/03-minimal-starter/package.json
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "rocket-minimal-starter",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"private": true,
|
||||||
|
"description": "Only includes the minimal basics",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"build": "rocket build",
|
||||||
|
"dev": "npm start",
|
||||||
|
"preview": "rocket preview --open",
|
||||||
|
"start": "NODE_DEBUG=engine:rendering rocket start --open"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@rocket/cli": "^0.20.0",
|
||||||
|
"@rocket/engine": "^0.2.0",
|
||||||
|
"lit": "^2.3.0"
|
||||||
|
},
|
||||||
|
"@rocket/template-name": "Minimal Starter"
|
||||||
|
}
|
||||||
11
examples/03-minimal-starter/site/pages/about.rocket.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
/* START - Rocket auto generated - do not touch */
|
||||||
|
export const sourceRelativeFilePath = 'about.rocket.js';
|
||||||
|
import { html, layout } from './recursive.data.js';
|
||||||
|
export { html, layout };
|
||||||
|
/* END - Rocket auto generated - do not touch */
|
||||||
|
|
||||||
|
export default () => html`
|
||||||
|
<h1>About</h1>
|
||||||
|
|
||||||
|
<a href="./index.rocket.html">to Home</a>
|
||||||
|
`;
|
||||||