Compare commits
11 Commits
@rocket/la
...
@rocket/cl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
156719f977 | ||
|
|
295cfbdbd8 | ||
|
|
7dd6f4c64f | ||
|
|
b68923b608 | ||
|
|
86c3a4b0e8 | ||
|
|
897892d6f9 | ||
|
|
7b2dc6430f | ||
|
|
2a400e09da | ||
|
|
25adb741d8 | ||
|
|
485827127d | ||
|
|
ef3b846bb9 |
@@ -18,38 +18,6 @@ module.exports = function (eleventyConfig) {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
As mdjs does return html AND javascript at the same time we need to have a template that can understand it. For that we create a layout file.
|
|
||||||
|
|
||||||
👉 `_includes/layout.njk`
|
|
||||||
|
|
||||||
{% raw %}
|
|
||||||
|
|
||||||
```js
|
|
||||||
<main>
|
|
||||||
{{ content.html | safe }}
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<script type="module">
|
|
||||||
{{ content.jsCode | safe }}
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
{% endraw %}
|
|
||||||
|
|
||||||
And in our content we then need to make sure to use that template.
|
|
||||||
|
|
||||||
👉 `index.md`
|
|
||||||
|
|
||||||
```
|
|
||||||
---
|
|
||||||
layout: layout.njk
|
|
||||||
---
|
|
||||||
|
|
||||||
# Hello World
|
|
||||||
```
|
|
||||||
|
|
||||||
You can see a minimal setup in the [examples repo](https://github.com/daKmoR/rocket-example-projects/tree/master/eleventy-and-mdjs).
|
|
||||||
|
|
||||||
## Configure a unified or remark plugin with mdjs
|
## Configure a unified or remark plugin with mdjs
|
||||||
|
|
||||||
By providing a `setupUnifiedPlugins` function as an option to `eleventy-plugin-mdjs` you can set options for all unified/remark plugins.
|
By providing a `setupUnifiedPlugins` function as an option to `eleventy-plugin-mdjs` you can set options for all unified/remark plugins.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Go Live >> Overview
|
# Go Live >> Overview ||10
|
||||||
|
|
||||||
A few things are usually needed before going live "for real".
|
A few things are usually needed before going live "for real".
|
||||||
|
|
||||||
|
|||||||
44
docs/guides/go-live/social-media.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Go Live >> Social Media ||20
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
<img src="{{ socialMediaImage }}" width="1200" height="630" alt="Social Media Image of this page" style="border: 1px solid #000" />
|
||||||
|
|
||||||
|
There are multiple ways you can modify it.
|
||||||
|
|
||||||
|
## Setting it via frontMatter
|
||||||
|
|
||||||
|
You can create your own image and link it with something like this
|
||||||
|
|
||||||
|
```
|
||||||
|
---
|
||||||
|
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 `createPageSocialImage` but provide your own values.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { createPageSocialImage } = require('@rocket/cli');
|
||||||
|
|
||||||
|
module.exports = async function () {
|
||||||
|
const socialMediaImage = await createPageSocialImage({
|
||||||
|
title: 'Learning Rocket',
|
||||||
|
subTitle: 'Have a website',
|
||||||
|
subTitle2: 'in 5 Minutes',
|
||||||
|
footer: 'Rocket Guides',
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
socialMediaImage,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
```
|
||||||
13
docs/guides/index.11tydata.cjs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
const { createPageSocialImage } = require('@rocket/cli');
|
||||||
|
|
||||||
|
module.exports = async function () {
|
||||||
|
const socialMediaImage = await createPageSocialImage({
|
||||||
|
title: 'Learning Rocket',
|
||||||
|
subTitle: 'Have a website',
|
||||||
|
subTitle2: 'in 5 Minutes',
|
||||||
|
footer: 'Rocket Guides',
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
socialMediaImage,
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
---
|
---
|
||||||
title: Learning Rocket
|
title: Learning Rocket
|
||||||
description: 'foo'
|
|
||||||
eleventyNavigation:
|
eleventyNavigation:
|
||||||
key: Guides
|
key: Guides
|
||||||
order: 10
|
order: 10
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Presets >> Overriding presets ||20
|
# Presets >> Overriding ||20
|
||||||
|
|
||||||
All loaded presets will be combined but you can override each file.
|
All loaded presets will be combined but you can override each file.
|
||||||
|
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
# Presets >> Using preset templates ||30
|
# Presets >> Using templates ||30
|
||||||
|
|
||||||
Most presetse have specific entry files you can override...
|
Most presetse have specific entry files you can override...
|
||||||
13
docs/index.11tydata.cjs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
const { createPageSocialImage } = require('@rocket/cli');
|
||||||
|
|
||||||
|
module.exports = async function () {
|
||||||
|
const socialMediaImage = await createPageSocialImage({
|
||||||
|
title: 'Rocket',
|
||||||
|
subTitle: 'Static sites with',
|
||||||
|
subTitle2: 'a sprinkle of JavaScript.',
|
||||||
|
footer: 'A Modern Web Product',
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
socialMediaImage,
|
||||||
|
};
|
||||||
|
};
|
||||||
23
package.json
@@ -28,6 +28,7 @@
|
|||||||
"rocket:build": "node packages/cli/src/cli.js build",
|
"rocket:build": "node packages/cli/src/cli.js build",
|
||||||
"search": "node packages/cli/src/cli.js search",
|
"search": "node packages/cli/src/cli.js search",
|
||||||
"setup": "npm run setup:ts-configs",
|
"setup": "npm run setup:ts-configs",
|
||||||
|
"setup:patches": "npx patch-package",
|
||||||
"setup:ts-configs": "node scripts/generate-ts-configs.mjs",
|
"setup:ts-configs": "node scripts/generate-ts-configs.mjs",
|
||||||
"start": "node packages/cli/src/cli.js start",
|
"start": "node packages/cli/src/cli.js start",
|
||||||
"test": "yarn test:node && yarn test:web",
|
"test": "yarn test:node && yarn test:web",
|
||||||
@@ -50,22 +51,22 @@
|
|||||||
"@types/chai": "^4.2.14",
|
"@types/chai": "^4.2.14",
|
||||||
"@types/fs-extra": "^9.0.6",
|
"@types/fs-extra": "^9.0.6",
|
||||||
"@types/mocha": "^8.2.0",
|
"@types/mocha": "^8.2.0",
|
||||||
"@types/node": "^14.14.16",
|
"@types/node": "^14.14.20",
|
||||||
"@types/sinon": "^9.0.10",
|
"@types/sinon": "^9.0.10",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.11.1",
|
"@typescript-eslint/eslint-plugin": "^4.13.0",
|
||||||
"@typescript-eslint/parser": "^4.11.1",
|
"@typescript-eslint/parser": "^4.13.0",
|
||||||
"@web/test-runner": "^0.11.5",
|
"@web/test-runner": "^0.12.2",
|
||||||
"@web/test-runner-commands": "^0.3.0",
|
"@web/test-runner-commands": "^0.4.0",
|
||||||
"@web/test-runner-playwright": "^0.7.0",
|
"@web/test-runner-playwright": "^0.8.0",
|
||||||
"chai": "^4.2.0",
|
"chai": "^4.2.0",
|
||||||
"concurrently": "^5.3.0",
|
"concurrently": "^5.3.0",
|
||||||
"copyfiles": "^2.4.1",
|
"copyfiles": "^2.4.1",
|
||||||
"deepmerge": "^4.2.2",
|
"deepmerge": "^4.2.2",
|
||||||
"esbuild": "^0.8.26",
|
"esbuild": "^0.8.31",
|
||||||
"eslint": "^7.16.0",
|
"eslint": "^7.17.0",
|
||||||
"eslint-config-prettier": "^7.1.0",
|
"eslint-config-prettier": "^7.1.0",
|
||||||
"hanbi": "^0.4.1",
|
"hanbi": "^0.4.1",
|
||||||
"husky": "^4.3.6",
|
"husky": "^4.3.7",
|
||||||
"lint-staged": "^10.5.3",
|
"lint-staged": "^10.5.3",
|
||||||
"mocha": "^8.2.1",
|
"mocha": "^8.2.1",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
@@ -76,9 +77,9 @@
|
|||||||
"puppeteer": "^5.5.0",
|
"puppeteer": "^5.5.0",
|
||||||
"remark-emoji": "^2.1.0",
|
"remark-emoji": "^2.1.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rollup": "^2.35.1",
|
"rollup": "^2.36.1",
|
||||||
"rollup-plugin-terser": "^7.0.2",
|
"rollup-plugin-terser": "^7.0.2",
|
||||||
"sinon": "^9.2.2",
|
"sinon": "^9.2.3",
|
||||||
"ts-node": "^9.1.1",
|
"ts-node": "^9.1.1",
|
||||||
"typescript": "^4.1.3"
|
"typescript": "^4.1.3"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @rocket/blog
|
# @rocket/blog
|
||||||
|
|
||||||
|
## 0.2.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- 4858271: Adjust templates for change in `@rocket/eleventy-plugin-mdjs-unified` as it now returns html directly instead of an object with html, js, stories
|
||||||
|
|
||||||
## 0.1.1
|
## 0.1.1
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rocket/blog",
|
"name": "@rocket/blog",
|
||||||
"version": "0.1.1",
|
"version": "0.2.0",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% include 'partials/addTitleHeadline.njk' %}
|
{% include 'partials/addTitleHeadline.njk' %}
|
||||||
|
|
||||||
{{ content.html | safe }}
|
{{ content | safe }}
|
||||||
|
|
||||||
{% include 'partials/previousNext.njk' %}
|
{% include 'partials/previousNext.njk' %}
|
||||||
{% include 'partials/blog-content-footer.njk' %}
|
{% include 'partials/blog-content-footer.njk' %}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
{% block main %}
|
{% block main %}
|
||||||
<main class="markdown-body">
|
<main class="markdown-body">
|
||||||
{% include 'partials/addTitleHeadline.njk' %}
|
{% include 'partials/addTitleHeadline.njk' %}
|
||||||
{{ content.html | safe }}
|
{{ content | safe }}
|
||||||
<div class="articles">
|
<div class="articles">
|
||||||
{% for post in posts %}
|
{% for post in posts %}
|
||||||
{% if post.data.published %}
|
{% if post.data.published %}
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @rocket/building-rollup
|
# @rocket/building-rollup
|
||||||
|
|
||||||
|
## 0.1.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 897892d: bump dependencies
|
||||||
|
|
||||||
## 0.1.1
|
## 0.1.1
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rocket/building-rollup",
|
"name": "@rocket/building-rollup",
|
||||||
"version": "0.1.1",
|
"version": "0.1.2",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
"@web/rollup-plugin-html": "^1.4.0",
|
"@web/rollup-plugin-html": "^1.4.0",
|
||||||
"@web/rollup-plugin-import-meta-assets": "^1.0.4",
|
"@web/rollup-plugin-import-meta-assets": "^1.0.4",
|
||||||
"@web/rollup-plugin-polyfills-loader": "^1.0.3",
|
"@web/rollup-plugin-polyfills-loader": "^1.0.3",
|
||||||
"browserslist": "^4.16.0",
|
"browserslist": "^4.16.1",
|
||||||
"rollup-plugin-terser": "^7.0.2",
|
"rollup-plugin-terser": "^7.0.2",
|
||||||
"rollup-plugin-workbox": "^6.1.0"
|
"rollup-plugin-workbox": "^6.1.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,34 @@
|
|||||||
# @rocket/cli
|
# @rocket/cli
|
||||||
|
|
||||||
|
## 0.2.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 897892d: bump dependencies
|
||||||
|
- 295cfbd: Better support for windows paths
|
||||||
|
- Updated dependencies [897892d]
|
||||||
|
- @rocket/building-rollup@0.1.2
|
||||||
|
- @rocket/eleventy-rocket-nav@0.2.1
|
||||||
|
|
||||||
|
## 0.2.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- ef3b846: Add a default "core" preset to the cli package which provides fundaments like eleventConfig data, eleventyComputed data, logo, site name, simple layout, ...
|
||||||
|
- 4858271: Process local relative links and images via html (11ty transform) to support all 11ty template systems
|
||||||
|
- 4858271: Adjust templates for change in `@rocket/eleventy-plugin-mdjs-unified` as it now returns html directly instead of an object with html, js, stories
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- ef3b846: Move setting of title, eleventyNavigation and section page meta data to eleventyComputed
|
||||||
|
- ef3b846: Auto create social media images for every page
|
||||||
|
- Updated dependencies [ef3b846]
|
||||||
|
- Updated dependencies [4858271]
|
||||||
|
- Updated dependencies [4858271]
|
||||||
|
- @rocket/core@0.1.1
|
||||||
|
- @rocket/eleventy-plugin-mdjs-unified@0.2.0
|
||||||
|
- @rocket/eleventy-rocket-nav@0.2.0
|
||||||
|
|
||||||
## 0.1.4
|
## 0.1.4
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
const { setComputedConfig, getComputedConfig } = require('./src/public/computedConfig.cjs');
|
const { setComputedConfig, getComputedConfig } = require('./src/public/computedConfig.cjs');
|
||||||
|
const rocketEleventyComputed = require('./src/public/rocketEleventyComputed.cjs');
|
||||||
|
const { createPageSocialImage } = require('./src/public/createPageSocialImage.cjs');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
setComputedConfig,
|
setComputedConfig,
|
||||||
getComputedConfig,
|
getComputedConfig,
|
||||||
|
rocketEleventyComputed,
|
||||||
|
createPageSocialImage,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rocket/cli",
|
"name": "@rocket/cli",
|
||||||
"version": "0.1.4",
|
"version": "0.2.1",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -38,6 +38,7 @@
|
|||||||
"*.mjs",
|
"*.mjs",
|
||||||
"dist",
|
"dist",
|
||||||
"dist-types",
|
"dist-types",
|
||||||
|
"preset",
|
||||||
"src"
|
"src"
|
||||||
],
|
],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -50,15 +51,16 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@11ty/eleventy": "^0.11.1",
|
"@11ty/eleventy": "^0.11.1",
|
||||||
"@rocket/building-rollup": "^0.1.1",
|
"@11ty/eleventy-img": "^0.7.4",
|
||||||
"@rocket/core": "^0.1.0",
|
"@rocket/building-rollup": "^0.1.2",
|
||||||
"@rocket/eleventy-plugin-mdjs-unified": "^0.1.0",
|
"@rocket/core": "^0.1.1",
|
||||||
"@rocket/eleventy-rocket-nav": "^0.1.0",
|
"@rocket/eleventy-plugin-mdjs-unified": "^0.2.0",
|
||||||
|
"@rocket/eleventy-rocket-nav": "^0.2.1",
|
||||||
"@rollup/plugin-babel": "^5.2.2",
|
"@rollup/plugin-babel": "^5.2.2",
|
||||||
"@rollup/plugin-node-resolve": "^11.0.1",
|
"@rollup/plugin-node-resolve": "^11.0.1",
|
||||||
"@web/config-loader": "^0.1.3",
|
"@web/config-loader": "^0.1.3",
|
||||||
"@web/dev-server": "^0.1.2",
|
"@web/dev-server": "^0.1.4",
|
||||||
"@web/dev-server-rollup": "^0.3.0",
|
"@web/dev-server-rollup": "^0.3.2",
|
||||||
"@web/rollup-plugin-copy": "^0.2.0",
|
"@web/rollup-plugin-copy": "^0.2.0",
|
||||||
"command-line-args": "^5.1.1",
|
"command-line-args": "^5.1.1",
|
||||||
"command-line-usage": "^6.1.1",
|
"command-line-usage": "^6.1.1",
|
||||||
|
|||||||
33
packages/cli/preset/_assets/logo.svg
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<svg fill="#e63946" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
viewBox="0 0 511.998 511.998" xml:space="preserve">
|
||||||
|
<g>
|
||||||
|
<path d="M98.649,430.256c-46.365,28.67-71.17,30.939-78.916,23.51c-7.75-7.433-6.519-32.307,20.182-79.832
|
||||||
|
c24.953-44.412,65.374-96.693,113.818-147.211l-11.279-10.817C93.124,267.348,51.871,320.751,26.291,366.279
|
||||||
|
c-19.228,34.22-37.848,79.134-17.375,98.766c5.84,5.6,13.599,7.935,22.484,7.935c22.269,0,51.606-14.677,75.469-29.432
|
||||||
|
c44.416-27.464,96.044-70.919,145.373-122.362l-11.279-10.817C192.517,360.888,141.976,403.464,98.649,430.256z"/>
|
||||||
|
|
||||||
|
<rect x="238.112" y="272.64" transform="matrix(-0.7218 -0.6921 0.6921 -0.7218 237.9094 656.5383)" width="25.589" height="15.628"/>
|
||||||
|
|
||||||
|
<rect x="268.895" y="302.163" transform="matrix(-0.7218 -0.6921 0.6921 -0.7218 270.4774 728.6761)" width="25.589" height="15.628"/>
|
||||||
|
|
||||||
|
<rect x="232.827" y="268.929" transform="matrix(-0.7218 -0.6921 0.6921 -0.7218 297.4719 673.0591)" width="102.364" height="15.628"/>
|
||||||
|
<path d="M500.916,41.287c-7.769,1.59-76.412,16.062-93.897,34.294l-50.728,52.899l-114.703-3.629l-39.198,40.876l79.28,40.569
|
||||||
|
l-21.755,22.687l72.848,69.858l21.755-22.687l43.857,77.51l39.197-40.876l-8.433-114.451l50.727-52.899
|
||||||
|
c17.485-18.234,29.067-87.422,30.331-95.251l1.801-11.169L500.916,41.287z M228.209,161.383l19.842-20.692l93.688,2.964
|
||||||
|
l-48.775,50.864L228.209,161.383z M401.632,327.686l-35.822-63.308l48.776-50.865l6.886,93.482L401.632,327.686z
|
||||||
|
M332.298,276.743l-50.287-48.223L412.89,92.037l50.288,48.223L332.298,276.743z M473.009,128.036l-48.316-46.334
|
||||||
|
c14.54-8.427,44.787-17.217,68.076-22.632C488.336,82.567,480.82,113.155,473.009,128.036z"/>
|
||||||
|
|
||||||
|
<rect x="302.369" y="231.988" transform="matrix(-0.7218 -0.6921 0.6921 -0.7218 384.0262 633.9694)" width="34.12" height="15.628"/>
|
||||||
|
|
||||||
|
<rect x="411.311" y="127.35" transform="matrix(-0.6921 0.7218 -0.7218 -0.6921 807.9747 -74.331)" width="17.061" height="15.628"/>
|
||||||
|
|
||||||
|
<rect x="394.288" y="145.087" transform="matrix(-0.7218 -0.6921 0.6921 -0.7218 586.0206 542.7934)" width="15.628" height="17.06"/>
|
||||||
|
|
||||||
|
<rect x="376.571" y="163.565" transform="matrix(-0.7218 -0.6921 0.6921 -0.7218 542.7271 562.3462)" width="15.628" height="17.06"/>
|
||||||
|
|
||||||
|
<rect x="161.111" y="185.158" transform="matrix(0.7071 0.7071 -0.7071 0.7071 192.1943 -60.3323)" width="15.628" height="33.35"/>
|
||||||
|
|
||||||
|
<rect x="184.683" y="172.695" transform="matrix(0.707 0.7072 -0.7072 0.707 182.4625 -83.9076)" width="15.628" height="11.118"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.5 KiB |
5
packages/cli/preset/_data/eleventyComputed.cjs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
const { rocketEleventyComputed } = require('@rocket/cli');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
...rocketEleventyComputed,
|
||||||
|
};
|
||||||
1
packages/cli/preset/_data/layout.cjs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
module.exports = 'layout.njk';
|
||||||
8
packages/cli/preset/_data/site.cjs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
module.exports = function () {
|
||||||
|
return {
|
||||||
|
dir: 'ltr',
|
||||||
|
lang: 'en',
|
||||||
|
name: 'Rocket',
|
||||||
|
description: 'Rocket is the way to build fast static websites with a sprinkle of javascript',
|
||||||
|
};
|
||||||
|
};
|
||||||
1
packages/cli/preset/_includes/layout.njk
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{{ content | safe }}
|
||||||
183
packages/cli/src/eleventy-plugins/processLocalReferences.cjs
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const { SaxEventType, SAXParser } = require('sax-wasm');
|
||||||
|
|
||||||
|
const saxPath = require.resolve('sax-wasm/lib/sax-wasm.wasm');
|
||||||
|
const saxWasmBuffer = fs.readFileSync(saxPath);
|
||||||
|
|
||||||
|
/** @typedef {import('./types').NavigationNode} NavigationNode */
|
||||||
|
/** @typedef {import('./types').Heading} Heading */
|
||||||
|
/** @typedef {import('./types').SaxData} SaxData */
|
||||||
|
|
||||||
|
// Instantiate
|
||||||
|
const parser = new SAXParser(
|
||||||
|
SaxEventType.Attribute,
|
||||||
|
{ highWaterMark: 256 * 1024 }, // 256k chunks
|
||||||
|
);
|
||||||
|
parser.prepareWasm(saxWasmBuffer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} link
|
||||||
|
*/
|
||||||
|
function isRelativeLink(link) {
|
||||||
|
if (link.startsWith('http') || link.startsWith('/')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const templateEndings = [
|
||||||
|
'.html',
|
||||||
|
'.md',
|
||||||
|
'.11ty.js',
|
||||||
|
'.liquid',
|
||||||
|
'.njk',
|
||||||
|
'.hbs',
|
||||||
|
'.mustache',
|
||||||
|
'.ejs',
|
||||||
|
'.haml',
|
||||||
|
'.pug',
|
||||||
|
];
|
||||||
|
|
||||||
|
function endsWithAny(string, suffixes) {
|
||||||
|
for (let suffix of suffixes) {
|
||||||
|
if (string.endsWith(suffix)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTemplateFile(href) {
|
||||||
|
return endsWithAny(href, templateEndings);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isIndexTemplateFile(href) {
|
||||||
|
const indexTemplateEndings = templateEndings.map(ending => `index${ending}`);
|
||||||
|
return endsWithAny(href, indexTemplateEndings);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} html
|
||||||
|
*/
|
||||||
|
function extractReferences(html, inputPath) {
|
||||||
|
const _html = html.replace(/\n/g, 'XXXRocketProcessLocalReferencesXXX');
|
||||||
|
const hrefs = [];
|
||||||
|
const assets = [];
|
||||||
|
parser.eventHandler = (ev, _data) => {
|
||||||
|
const data = /** @type {SaxData} */ (/** @type {any} */ (_data));
|
||||||
|
if (ev === SaxEventType.Attribute) {
|
||||||
|
const attributeName = data.name.toString();
|
||||||
|
const value = data.value.toString();
|
||||||
|
const entry = {
|
||||||
|
value,
|
||||||
|
startCharacter: data.value.start.character,
|
||||||
|
};
|
||||||
|
if (attributeName === 'href') {
|
||||||
|
if (isRelativeLink(value)) {
|
||||||
|
hrefs.push(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (attributeName === 'src' || attributeName === 'srcset') {
|
||||||
|
if (isRelativeLink(value) && !isIndexTemplateFile(inputPath)) {
|
||||||
|
assets.push(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
parser.write(Buffer.from(_html));
|
||||||
|
parser.end();
|
||||||
|
|
||||||
|
return { hrefs, assets };
|
||||||
|
}
|
||||||
|
|
||||||
|
function calculateNewHrefs(hrefs, inputPath) {
|
||||||
|
const newHrefs = [];
|
||||||
|
for (const hrefObj of hrefs) {
|
||||||
|
const newHrefObj = { ...hrefObj };
|
||||||
|
const [href, anchor] = newHrefObj.value.split('#');
|
||||||
|
const suffix = anchor ? `#${anchor}` : '';
|
||||||
|
|
||||||
|
if (isRelativeLink(href) && isTemplateFile(href)) {
|
||||||
|
const hrefParsed = path.parse(href);
|
||||||
|
const dirPart = hrefParsed.dir.length > 1 ? `${hrefParsed.dir}/` : '';
|
||||||
|
newHrefObj.newValue = isIndexTemplateFile(href)
|
||||||
|
? `${dirPart}${suffix}`
|
||||||
|
: `${dirPart}${hrefParsed.name}/${suffix}`;
|
||||||
|
|
||||||
|
if (isTemplateFile(inputPath)) {
|
||||||
|
if (isIndexTemplateFile(inputPath)) {
|
||||||
|
// nothing
|
||||||
|
} else {
|
||||||
|
newHrefObj.newValue = path.join('../', newHrefObj.newValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newHrefObj.newValue) {
|
||||||
|
newHrefs.push(newHrefObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newHrefs;
|
||||||
|
}
|
||||||
|
|
||||||
|
function calculateNewAssets(assets) {
|
||||||
|
const newAssets = [...assets];
|
||||||
|
return newAssets.map(assetObj => {
|
||||||
|
assetObj.newValue = path.join('../', assetObj.value);
|
||||||
|
return assetObj;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function replaceContent(hrefObj, content) {
|
||||||
|
const upToChange = content.slice(0, hrefObj.startCharacter);
|
||||||
|
const afterChange = content.slice(hrefObj.startCharacter + hrefObj.value.length);
|
||||||
|
|
||||||
|
return `${upToChange}${hrefObj.newValue}${afterChange}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sortByStartCharacter(a, b) {
|
||||||
|
if (a.startCharacter > b.startCharacter) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (a.startCharacter < b.startCharacter) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyChanges(_changes, _content) {
|
||||||
|
// make sure changes are sorted as changes affect all other changes afterwards
|
||||||
|
let changes = [..._changes].sort(sortByStartCharacter);
|
||||||
|
|
||||||
|
let content = _content.replace(/\n/g, 'XXXRocketProcessLocalReferencesXXX');
|
||||||
|
|
||||||
|
while (changes.length > 0) {
|
||||||
|
const hrefObj = changes.shift();
|
||||||
|
const diff = hrefObj.newValue.length - hrefObj.value.length;
|
||||||
|
|
||||||
|
content = replaceContent(hrefObj, content);
|
||||||
|
|
||||||
|
changes = changes.map(href => {
|
||||||
|
href.startCharacter = href.startCharacter + diff;
|
||||||
|
return href;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return content.replace(/XXXRocketProcessLocalReferencesXXX/g, '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function processLocalReferences(content) {
|
||||||
|
const inputPath = this.inputPath;
|
||||||
|
const { hrefs, assets } = extractReferences(content, inputPath);
|
||||||
|
const newHrefs = calculateNewHrefs(hrefs, inputPath);
|
||||||
|
const newAssets = calculateNewAssets(assets, inputPath);
|
||||||
|
|
||||||
|
const newContent = applyChanges([...newHrefs, ...newAssets], content);
|
||||||
|
|
||||||
|
return newContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
processLocalReferences,
|
||||||
|
};
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { readdirSync } = require('fs');
|
const { readdirSync } = require('fs');
|
||||||
const { processContentWithTitle } = require('@rocket/core/title');
|
|
||||||
|
|
||||||
function getDirectories(source) {
|
function getDirectories(source) {
|
||||||
return readdirSync(source, { withFileTypes: true })
|
return readdirSync(source, { withFileTypes: true })
|
||||||
@@ -9,27 +8,6 @@ function getDirectories(source) {
|
|||||||
.map(dirent => dirent.name);
|
.map(dirent => dirent.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* adds title from markdown headline to all pages
|
|
||||||
*
|
|
||||||
* @param collection
|
|
||||||
*/
|
|
||||||
function setTitleForAll(collection) {
|
|
||||||
const all = collection.getAll();
|
|
||||||
all.forEach(page => {
|
|
||||||
page.data.addTitleHeadline = true;
|
|
||||||
const titleData = processContentWithTitle(
|
|
||||||
page.template.inputContent,
|
|
||||||
page.template._templateRender._engineName,
|
|
||||||
);
|
|
||||||
if (titleData) {
|
|
||||||
page.data.title = titleData.title;
|
|
||||||
page.data.eleventyNavigation = { ...titleData.eleventyNavigation };
|
|
||||||
page.data.addTitleHeadline = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const rocketCollections = {
|
const rocketCollections = {
|
||||||
configFunction: (eleventyConfig, { _inputDirCwdRelative }) => {
|
configFunction: (eleventyConfig, { _inputDirCwdRelative }) => {
|
||||||
const sectionNames = getDirectories(_inputDirCwdRelative);
|
const sectionNames = getDirectories(_inputDirCwdRelative);
|
||||||
@@ -45,13 +23,8 @@ const rocketCollections = {
|
|||||||
let docs = [
|
let docs = [
|
||||||
...collection.getFilteredByGlob(`${_inputDirCwdRelative}/${section}/**/*.md`),
|
...collection.getFilteredByGlob(`${_inputDirCwdRelative}/${section}/**/*.md`),
|
||||||
];
|
];
|
||||||
docs.forEach(page => {
|
|
||||||
page.data.section = section;
|
|
||||||
});
|
|
||||||
docs = docs.filter(page => page.inputPath !== `./${indexSection}`);
|
docs = docs.filter(page => page.inputPath !== `./${indexSection}`);
|
||||||
|
|
||||||
// docs = addPrevNextUrls(docs);
|
|
||||||
|
|
||||||
return docs;
|
return docs;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -71,8 +44,6 @@ const rocketCollections = {
|
|||||||
return aOrder - bOrder;
|
return aOrder - bOrder;
|
||||||
});
|
});
|
||||||
|
|
||||||
setTitleForAll(collection);
|
|
||||||
|
|
||||||
return headers;
|
return headers;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const { processLocalReferences } = require('./processLocalReferences.cjs');
|
||||||
|
|
||||||
function inlineFilePath(filePath) {
|
function inlineFilePath(filePath) {
|
||||||
let data = fs.readFileSync(filePath, function (err, contents) {
|
let data = fs.readFileSync(filePath, function (err, contents) {
|
||||||
@@ -22,6 +23,8 @@ const rocketFilters = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
eleventyConfig.addFilter('inlineFilePath', inlineFilePath);
|
eleventyConfig.addFilter('inlineFilePath', inlineFilePath);
|
||||||
|
|
||||||
|
eleventyConfig.addTransform('processLocalReferences', processLocalReferences);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ import { readConfig } from '@web/config-loader';
|
|||||||
import { RocketStart } from './RocketStart.js';
|
import { RocketStart } from './RocketStart.js';
|
||||||
import { RocketBuild } from './RocketBuild.js';
|
import { RocketBuild } from './RocketBuild.js';
|
||||||
|
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Partial<RocketCliOptions>} inConfig
|
* @param {Partial<RocketCliOptions>} inConfig
|
||||||
* @returns {Promise<RocketCliOptions>}
|
* @returns {Promise<RocketCliOptions>}
|
||||||
@@ -32,7 +36,7 @@ export async function normalizeConfig(inConfig) {
|
|||||||
watch: true,
|
watch: true,
|
||||||
inputDir: 'docs',
|
inputDir: 'docs',
|
||||||
outputDir: '_site',
|
outputDir: '_site',
|
||||||
outputDevDir: path.resolve('_site-dev'),
|
outputDevDir: '_site-dev',
|
||||||
build: {},
|
build: {},
|
||||||
devServer: {},
|
devServer: {},
|
||||||
|
|
||||||
@@ -75,7 +79,8 @@ export async function normalizeConfig(inConfig) {
|
|||||||
const _configDirCwdRelative = path.relative(process.cwd(), path.resolve(__configDir));
|
const _configDirCwdRelative = path.relative(process.cwd(), path.resolve(__configDir));
|
||||||
const _inputDirCwdRelative = path.join(_configDirCwdRelative, config.inputDir);
|
const _inputDirCwdRelative = path.join(_configDirCwdRelative, config.inputDir);
|
||||||
|
|
||||||
config._presetPathes = [];
|
// cli core preset is always first
|
||||||
|
config._presetPathes = [path.join(__dirname, '..', 'preset')];
|
||||||
for (const preset of config.presets) {
|
for (const preset of config.presets) {
|
||||||
config._presetPathes.push(preset.path);
|
config._presetPathes.push(preset.path);
|
||||||
|
|
||||||
|
|||||||
73
packages/cli/src/public/createPageSocialImage.cjs
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
|
const Image = require('@11ty/eleventy-img');
|
||||||
|
const { getComputedConfig } = require('./computedConfig.cjs');
|
||||||
|
|
||||||
|
async function createPageSocialImage({ title = '', subTitle = '', subTitle2 = '', footer = '' }) {
|
||||||
|
const rocketConfig = getComputedConfig();
|
||||||
|
const outputDir = path.join(rocketConfig.outputDevDir, '_merged_assets', '11ty-img');
|
||||||
|
|
||||||
|
const logoPath = path.join(rocketConfig._inputDirCwdRelative, '_merged_assets', 'logo.svg');
|
||||||
|
|
||||||
|
const logoBuffer = await fs.promises.readFile(logoPath);
|
||||||
|
const logo = logoBuffer.toString();
|
||||||
|
|
||||||
|
let svgStr = `
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" fill="#4a4a4a" font-family="sans-serif" font-size="80" style="background-color:#fff" viewBox="0 0 1200 630">
|
||||||
|
<defs></defs>
|
||||||
|
<rect width="100%" height="100%" fill="#fff" />
|
||||||
|
<circle cx="1000" cy="230" r="530" fill="#ebebeb"></circle>
|
||||||
|
`;
|
||||||
|
|
||||||
|
if (logo) {
|
||||||
|
svgStr += `<g transform="matrix(0.7, 0, 0, 0.7, 500, 100)">${logo}</g>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (title) {
|
||||||
|
svgStr += `
|
||||||
|
<text x="70" y="200" font-family="'Bitstream Vera Sans','Helvetica',sans-serif" font-weight="700">
|
||||||
|
${title}
|
||||||
|
</text>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subTitle) {
|
||||||
|
svgStr += `
|
||||||
|
<text x="70" y="320" font-family="'Bitstream Vera Sans','Helvetica',sans-serif" font-weight="700" font-size="60">
|
||||||
|
${subTitle}
|
||||||
|
</text>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subTitle2) {
|
||||||
|
svgStr += `
|
||||||
|
<text x="70" y="420" font-family="'Bitstream Vera Sans','Helvetica',sans-serif" font-weight="700" font-size="60">
|
||||||
|
${subTitle2}
|
||||||
|
</text>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (footer) {
|
||||||
|
svgStr += `
|
||||||
|
<text x="70" y="560" fill="gray" font-size="40">
|
||||||
|
${footer}
|
||||||
|
</text>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
svgStr += '</svg>';
|
||||||
|
|
||||||
|
let stats = await Image(Buffer.from(svgStr), {
|
||||||
|
widths: [1200], // Facebook Opengraph image is 1200 x 630
|
||||||
|
formats: ['png'],
|
||||||
|
outputDir,
|
||||||
|
urlPath: '/_merged_assets/11ty-img/',
|
||||||
|
sourceUrl: `${title}${subTitle}${footer}${logo}`, // This is only used to generate the output filename hash
|
||||||
|
});
|
||||||
|
|
||||||
|
return stats['png'][0].url;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
createPageSocialImage,
|
||||||
|
};
|
||||||
63
packages/cli/src/public/rocketEleventyComputed.cjs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const { processContentWithTitle } = require('@rocket/core/title');
|
||||||
|
const { createPageSocialImage } = require('./createPageSocialImage.cjs');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
titleMeta: async data => {
|
||||||
|
if (data.titleMeta) {
|
||||||
|
return data.titleMeta;
|
||||||
|
}
|
||||||
|
let text = await fs.promises.readFile(data.page.inputPath);
|
||||||
|
text = text.toString();
|
||||||
|
const titleMetaFromContent = processContentWithTitle(text, 'md');
|
||||||
|
if (titleMetaFromContent) {
|
||||||
|
return titleMetaFromContent;
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
title: async data => {
|
||||||
|
if (data.title) {
|
||||||
|
return data.title;
|
||||||
|
}
|
||||||
|
return data.titleMeta?.title;
|
||||||
|
},
|
||||||
|
eleventyNavigation: async data => {
|
||||||
|
if (data.eleventyNavigation) {
|
||||||
|
return data.eleventyNavigation;
|
||||||
|
}
|
||||||
|
return data.titleMeta?.eleventyNavigation;
|
||||||
|
},
|
||||||
|
section: async data => {
|
||||||
|
if (data.section) {
|
||||||
|
return data.section;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.page.filePathStem) {
|
||||||
|
// filePathStem: '/sub/subsub/index'
|
||||||
|
// filePathStem: '/index',
|
||||||
|
const parts = data.page.filePathStem.split('/');
|
||||||
|
if (parts.length > 2) {
|
||||||
|
return parts[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
socialMediaImage: async data => {
|
||||||
|
if (data.socialMediaImage) {
|
||||||
|
return data.socialMediaImage;
|
||||||
|
}
|
||||||
|
if (!data.title) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const section = data.section ? ' ' + data.section[0].toUpperCase() + data.section.slice(1) : '';
|
||||||
|
const footer = `${data.site.name}${section}`;
|
||||||
|
|
||||||
|
const imgUrl = await createPageSocialImage({
|
||||||
|
title: data.titleMeta.parts ? data.titleMeta.parts[0] : '',
|
||||||
|
subTitle:
|
||||||
|
data.titleMeta.parts && data.titleMeta.parts[1] ? `in ${data.titleMeta.parts[1]}` : '',
|
||||||
|
footer,
|
||||||
|
});
|
||||||
|
return imgUrl;
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -57,6 +57,11 @@ describe('RocketCli e2e', () => {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function readStartOutput(fileName, options = {}) {
|
||||||
|
options.type = 'start';
|
||||||
|
return readOutput(fileName, options);
|
||||||
|
}
|
||||||
|
|
||||||
async function execute() {
|
async function execute() {
|
||||||
await cli.setup();
|
await cli.setup();
|
||||||
cli.config.outputDevDir = path.join(__dirname, 'e2e-fixtures', '__output-dev');
|
cli.config.outputDevDir = path.join(__dirname, 'e2e-fixtures', '__output-dev');
|
||||||
@@ -67,6 +72,17 @@ describe('RocketCli e2e', () => {
|
|||||||
await cli.run();
|
await cli.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function executeStart(pathToConfig) {
|
||||||
|
cli = new RocketCli({
|
||||||
|
argv: [
|
||||||
|
'start',
|
||||||
|
'--config-file',
|
||||||
|
path.join(__dirname, pathToConfig.split('/').join(path.sep)),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
await execute();
|
||||||
|
}
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
if (cli?.cleanup) {
|
if (cli?.cleanup) {
|
||||||
await cli.cleanup();
|
await cli.cleanup();
|
||||||
@@ -199,7 +215,7 @@ describe('RocketCli e2e', () => {
|
|||||||
type: 'start',
|
type: 'start',
|
||||||
});
|
});
|
||||||
expect(indexHtml).to.equal(
|
expect(indexHtml).to.equal(
|
||||||
'<p>You can show rocket config data like rocketConfig.absoluteBaseUrl = http://test-domain.com/</p>',
|
'<p>You can show rocket config data like rocketConfig.absoluteBaseUrl = <a href="http://test-domain.com/">http://test-domain.com/</a></p>',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -249,7 +265,145 @@ describe('RocketCli e2e', () => {
|
|||||||
stripServiceWorker: true,
|
stripServiceWorker: true,
|
||||||
});
|
});
|
||||||
expect(assetHtml).to.equal(
|
expect(assetHtml).to.equal(
|
||||||
'<html><head><link rel="stylesheet" href="../41297ffa.css">\n\n\n\n</head><body>\n\n</body></html>',
|
'<html><head><link rel="stylesheet" href="../41297ffa.css">\n\n</head><body>\n\n</body></html>',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('will extract a title from markdown and set first folder as section', async () => {
|
||||||
|
cli = new RocketCli({
|
||||||
|
argv: [
|
||||||
|
'start',
|
||||||
|
'--config-file',
|
||||||
|
path.join(__dirname, 'e2e-fixtures', 'headlines', 'rocket.config.js'),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
await execute();
|
||||||
|
|
||||||
|
const indexHtml = await readOutput('index.html', {
|
||||||
|
type: 'start',
|
||||||
|
});
|
||||||
|
const [indexTitle, indexSection] = indexHtml.split('\n');
|
||||||
|
expect(indexTitle).to.equal('Root');
|
||||||
|
expect(indexSection).to.be.undefined;
|
||||||
|
|
||||||
|
const subHtml = await readOutput('sub/index.html', {
|
||||||
|
type: 'start',
|
||||||
|
});
|
||||||
|
const [subTitle, subSection] = subHtml.split('\n');
|
||||||
|
expect(subTitle).to.equal('Root: Sub');
|
||||||
|
expect(subSection).to.equal('sub');
|
||||||
|
|
||||||
|
const subSubHtml = await readOutput('sub/subsub/index.html', {
|
||||||
|
type: 'start',
|
||||||
|
});
|
||||||
|
const [subSubTitle, subSubSection] = subSubHtml.split('\n');
|
||||||
|
expect(subSubTitle).to.equal('Sub: SubSub');
|
||||||
|
expect(subSubSection).to.equal('sub');
|
||||||
|
|
||||||
|
const sub2Html = await readOutput('sub2/index.html', {
|
||||||
|
type: 'start',
|
||||||
|
});
|
||||||
|
const [sub2Title, sub2Section] = sub2Html.split('\n');
|
||||||
|
expect(sub2Title).to.equal('Root: Sub2');
|
||||||
|
expect(sub2Section).to.equal('sub2');
|
||||||
|
|
||||||
|
const withDataHtml = await readOutput('with-data/index.html', {
|
||||||
|
type: 'start',
|
||||||
|
});
|
||||||
|
const [withDataTitle, withDataSection] = withDataHtml.split('\n');
|
||||||
|
expect(withDataTitle).to.equal('Set via data');
|
||||||
|
expect(withDataSection).be.undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('will create a social media image for every page', async () => {
|
||||||
|
cli = new RocketCli({
|
||||||
|
argv: [
|
||||||
|
'start',
|
||||||
|
'--config-file',
|
||||||
|
path.join(__dirname, 'e2e-fixtures', 'social-images', 'rocket.config.js'),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
await execute();
|
||||||
|
|
||||||
|
const indexHtml = await readOutput('index.html', {
|
||||||
|
type: 'start',
|
||||||
|
});
|
||||||
|
expect(indexHtml).to.equal('/_merged_assets/11ty-img/c0a892f2-1200.png');
|
||||||
|
|
||||||
|
const guidesHtml = await readOutput('guides/first-pages/getting-started/index.html', {
|
||||||
|
type: 'start',
|
||||||
|
});
|
||||||
|
expect(guidesHtml).to.equal('/_merged_assets/11ty-img/58b7e437-1200.png');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('will add "../" for links and image urls only within named template files', async () => {
|
||||||
|
await executeStart('e2e-fixtures/image-link/rocket.config.js');
|
||||||
|
|
||||||
|
const namedMdContent = [
|
||||||
|
'<p><a href="../">Root</a>',
|
||||||
|
'<a href="../guides/#with-anchor">Guides</a>',
|
||||||
|
'<a href="../one-level/raw/">Raw</a>',
|
||||||
|
'<a href="../../up-one-level/template/">Template</a>',
|
||||||
|
'<img src="../images-one-level/my-img.svg" alt="my-img">',
|
||||||
|
'<img src="/absolute-img.svg" alt="absolute-img"></p>',
|
||||||
|
];
|
||||||
|
|
||||||
|
const namedHtmlContent = [
|
||||||
|
'<div>',
|
||||||
|
' <a href="../">Root</a>',
|
||||||
|
' <a href="../guides/#with-anchor">Guides</a>',
|
||||||
|
' <a href="../one-level/raw/">Raw</a>',
|
||||||
|
' <a href="../../up-one-level/template/">Template</a>',
|
||||||
|
' <img src="../images-one-level/my-img.svg" alt="my-img">',
|
||||||
|
' <img src="/absolute-img.svg" alt="absolute-img">',
|
||||||
|
' <picture>',
|
||||||
|
' <source media="(min-width:465px)" srcset="../picture-min-465.jpg">',
|
||||||
|
' <img src="../../images-up-one-level/picture-fallback.jpg" alt="Fallback" style="width:auto;">',
|
||||||
|
' </picture>',
|
||||||
|
'</div>',
|
||||||
|
];
|
||||||
|
|
||||||
|
const rawHtml = await readStartOutput('raw/index.html');
|
||||||
|
expect(rawHtml, 'raw/index.html does not match').to.equal(namedHtmlContent.join('\n'));
|
||||||
|
|
||||||
|
const templateHtml = await readStartOutput('template/index.html');
|
||||||
|
expect(templateHtml, 'template/index.html does not match').to.equal(
|
||||||
|
namedHtmlContent.join('\n'),
|
||||||
|
);
|
||||||
|
|
||||||
|
const guidesHtml = await readStartOutput('guides/index.html');
|
||||||
|
expect(guidesHtml, 'guides/index.html does not match').to.equal(
|
||||||
|
[...namedMdContent, ...namedHtmlContent].join('\n'),
|
||||||
|
);
|
||||||
|
|
||||||
|
const noAdjustHtml = await readStartOutput('no-adjust/index.html');
|
||||||
|
expect(noAdjustHtml, 'no-adjust/index.html does not match').to.equal(
|
||||||
|
'<p>Nothing to adjust in here</p>',
|
||||||
|
);
|
||||||
|
|
||||||
|
// for index files no '../' will be added
|
||||||
|
const indexHtml = await readStartOutput('index.html');
|
||||||
|
expect(indexHtml, 'index.html does not match').to.equal(
|
||||||
|
[
|
||||||
|
'<p><a href="./">Root</a>',
|
||||||
|
'<a href="guides/#with-anchor">Guides</a>',
|
||||||
|
'<a href="./one-level/raw/">Raw</a>',
|
||||||
|
'<a href="../up-one-level/template/">Template</a>',
|
||||||
|
'<img src="./images-one-level/my-img.svg" alt="my-img">',
|
||||||
|
'<img src="/absolute-img.svg" alt="absolute-img"></p>',
|
||||||
|
'<div>',
|
||||||
|
' <a href="./">Root</a>',
|
||||||
|
' <a href="guides/#with-anchor">Guides</a>',
|
||||||
|
' <a href="./one-level/raw/">Raw</a>',
|
||||||
|
' <a href="../up-one-level/template/">Template</a>',
|
||||||
|
' <img src="./images-one-level/my-img.svg" alt="my-img">',
|
||||||
|
' <img src="/absolute-img.svg" alt="absolute-img">',
|
||||||
|
' <picture>',
|
||||||
|
' <source media="(min-width:465px)" srcset="./picture-min-465.jpg">',
|
||||||
|
' <img src="../images-up-one-level/picture-fallback.jpg" alt="Fallback" style="width:auto;">',
|
||||||
|
' </picture>',
|
||||||
|
'</div>',
|
||||||
|
].join('\n'),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
{{ content.html | safe }}
|
|
||||||
|
|
||||||
{% if content.jsCode %}
|
|
||||||
<script type="module">
|
|
||||||
{{ content.jsCode | safe }}
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
@@ -1,5 +1 @@
|
|||||||
---
|
|
||||||
layout: layout.njk
|
|
||||||
---
|
|
||||||
|
|
||||||
Markdown in `docs/page/index.md`
|
Markdown in `docs/page/index.md`
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
{{ content.html | safe }}
|
|
||||||
|
|
||||||
{% if content.jsCode %}
|
|
||||||
<script type="module">
|
|
||||||
{{ content.jsCode | safe }}
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
**/*.njk
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
module.exports = 'do-not-generate-it';
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
{{ title }}
|
||||||
|
{{ section }}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# Root
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# Root >> Sub
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# Root >> Sub >> SubSub ||10
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# Root >> Sub2
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
title: Set via data
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/** @type {Partial<import("../../../types/main").RocketCliOptions>} */
|
||||||
|
const config = {};
|
||||||
|
|
||||||
|
export default config;
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
[Root](./index.md)
|
||||||
|
[Guides](./guides.md#with-anchor)
|
||||||
|
[Raw](./one-level/raw.html)
|
||||||
|
[Template](../up-one-level/template.njk)
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
<div>
|
||||||
|
<a href="./index.md">Root</a>
|
||||||
|
<a href="./guides.md#with-anchor">Guides</a>
|
||||||
|
<a href="./one-level/raw.html">Raw</a>
|
||||||
|
<a href="../up-one-level/template.njk">Template</a>
|
||||||
|
<img src="./images-one-level/my-img.svg" alt="my-img">
|
||||||
|
<img src="/absolute-img.svg" alt="absolute-img">
|
||||||
|
<picture>
|
||||||
|
<source media="(min-width:465px)" srcset="./picture-min-465.jpg">
|
||||||
|
<img src="../images-up-one-level/picture-fallback.jpg" alt="Fallback" style="width:auto;">
|
||||||
|
</picture>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<svg height="100" width="100">
|
||||||
|
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 118 B |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 62 KiB |
19
packages/cli/test-node/e2e-fixtures/image-link/docs/index.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
[Root](./)
|
||||||
|
[Guides](./guides.md#with-anchor)
|
||||||
|
[Raw](./one-level/raw.html)
|
||||||
|
[Template](../up-one-level/template.njk)
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
<div>
|
||||||
|
<a href="./">Root</a>
|
||||||
|
<a href="./guides.md#with-anchor">Guides</a>
|
||||||
|
<a href="./one-level/raw.html">Raw</a>
|
||||||
|
<a href="../up-one-level/template.njk">Template</a>
|
||||||
|
<img src="./images-one-level/my-img.svg" alt="my-img">
|
||||||
|
<img src="/absolute-img.svg" alt="absolute-img">
|
||||||
|
<picture>
|
||||||
|
<source media="(min-width:465px)" srcset="./picture-min-465.jpg">
|
||||||
|
<img src="../images-up-one-level/picture-fallback.jpg" alt="Fallback" style="width:auto;">
|
||||||
|
</picture>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Nothing to adjust in here
|
||||||
12
packages/cli/test-node/e2e-fixtures/image-link/docs/raw.html
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<div>
|
||||||
|
<a href="./index.md">Root</a>
|
||||||
|
<a href="./guides.md#with-anchor">Guides</a>
|
||||||
|
<a href="./one-level/raw.html">Raw</a>
|
||||||
|
<a href="../up-one-level/template.njk">Template</a>
|
||||||
|
<img src="./images-one-level/my-img.svg" alt="my-img">
|
||||||
|
<img src="/absolute-img.svg" alt="absolute-img">
|
||||||
|
<picture>
|
||||||
|
<source media="(min-width:465px)" srcset="./picture-min-465.jpg">
|
||||||
|
<img src="../images-up-one-level/picture-fallback.jpg" alt="Fallback" style="width:auto;">
|
||||||
|
</picture>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<div>
|
||||||
|
<a href="./index.md">Root</a>
|
||||||
|
<a href="./guides.md#with-anchor">Guides</a>
|
||||||
|
<a href="./one-level/raw.html">Raw</a>
|
||||||
|
<a href="../up-one-level/template.njk">Template</a>
|
||||||
|
<img src="./images-one-level/my-img.svg" alt="my-img">
|
||||||
|
<img src="/absolute-img.svg" alt="absolute-img">
|
||||||
|
<picture>
|
||||||
|
<source media="(min-width:465px)" srcset="./picture-min-465.jpg">
|
||||||
|
<img src="../images-up-one-level/picture-fallback.jpg" alt="Fallback" style="width:auto;">
|
||||||
|
</picture>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
/** @type {Partial<import("../../../types/main").RocketCliOptions>} */
|
||||||
|
const config = {};
|
||||||
|
export default config;
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
{{ content.html | safe }}
|
|
||||||
|
|
||||||
{% if content.jsCode %}
|
|
||||||
<script type="module">
|
|
||||||
{{ content.jsCode | safe }}
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
@@ -1,5 +1 @@
|
|||||||
---
|
|
||||||
layout: layout.njk
|
|
||||||
---
|
|
||||||
|
|
||||||
You can show rocket config data like rocketConfig.absoluteBaseUrl = {{rocketConfig.absoluteBaseUrl}}
|
You can show rocket config data like rocketConfig.absoluteBaseUrl = {{rocketConfig.absoluteBaseUrl}}
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
{{ content.html | safe }}
|
|
||||||
|
|
||||||
{% if content.jsCode %}
|
|
||||||
<script type="module">
|
|
||||||
{{ content.jsCode | safe }}
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
**/*.njk
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{{ socialMediaImage }}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# First Pages >> Getting Started
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
const { createPageSocialImage } = require('@rocket/cli');
|
||||||
|
|
||||||
|
module.exports = async function () {
|
||||||
|
const socialMediaImage = await createPageSocialImage({
|
||||||
|
title: 'Rocket',
|
||||||
|
subTitle: 'Static sites with',
|
||||||
|
subTitle2: 'a sprinkle of JavaScript.',
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
socialMediaImage,
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# Rocket
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/** @type {Partial<import("../../../types/main").RocketCliOptions>} */
|
||||||
|
const config = {};
|
||||||
|
|
||||||
|
export default config;
|
||||||
@@ -1 +0,0 @@
|
|||||||
{{ content.html | safe }}
|
|
||||||
@@ -23,7 +23,8 @@ describe('normalizeConfig', () => {
|
|||||||
|
|
||||||
// testing pathes is always a little more complicted 😅
|
// testing pathes is always a little more complicted 😅
|
||||||
expect(config._inputDirCwdRelative).to.match(/empty\/docs$/);
|
expect(config._inputDirCwdRelative).to.match(/empty\/docs$/);
|
||||||
expect(config._presetPathes[0]).to.match(/empty\/docs$/);
|
expect(config._presetPathes[0]).to.match(/cli\/preset$/);
|
||||||
|
expect(config._presetPathes[1]).to.match(/empty\/docs$/);
|
||||||
expect(config.outputDevDir).to.match(/_site-dev$/);
|
expect(config.outputDevDir).to.match(/_site-dev$/);
|
||||||
|
|
||||||
expect(cleanup(config)).to.deep.equal({
|
expect(cleanup(config)).to.deep.equal({
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
# @rocket/core
|
# @rocket/core
|
||||||
|
|
||||||
|
## 0.1.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- ef3b846: Enhance markdown title processing to return additional metaData (e.g. all parent parts)
|
||||||
|
|
||||||
## 0.1.0
|
## 0.1.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|
||||||
- 1971f5d: Initial Release
|
- 1971f5d: Initial Release
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rocket/core",
|
"name": "@rocket/core",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -26,7 +26,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build:package": "rimraf dist && esbuild --platform=node --format=cjs --bundle --outfile=dist/title.cjs ./src/title/index.js",
|
"build:package": "rimraf dist && esbuild --platform=node --format=cjs --bundle --outfile=dist/title.cjs ./src/title/index.js",
|
||||||
"build:types": "tsc -p tsconfig.build.types.json",
|
"build:types": "tsc -p tsconfig.build.types.json",
|
||||||
"test": "cd ../../ && yarn test:browser \"packages/navigation2/test/**/*.test.js\"",
|
"debug": "cd ../../ && yarn debug --group core",
|
||||||
|
"test": "cd ../../ && yarn test:web --group core",
|
||||||
"test:watch": "yarn test --watch"
|
"test:watch": "yarn test --watch"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export function parseTitle(inTitle) {
|
|||||||
let order = 0;
|
let order = 0;
|
||||||
let navigationTitle = title;
|
let navigationTitle = title;
|
||||||
let parent;
|
let parent;
|
||||||
|
let titleParts = [title];
|
||||||
if (title.includes('>>')) {
|
if (title.includes('>>')) {
|
||||||
const parts = title
|
const parts = title
|
||||||
.split('>>')
|
.split('>>')
|
||||||
@@ -41,6 +42,7 @@ export function parseTitle(inTitle) {
|
|||||||
title = `${parts[parts.length - 2]}: ${parts[parts.length - 1]}`;
|
title = `${parts[parts.length - 2]}: ${parts[parts.length - 1]}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
titleParts = [...parts].reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (title.includes('||')) {
|
if (title.includes('||')) {
|
||||||
@@ -51,12 +53,15 @@ export function parseTitle(inTitle) {
|
|||||||
if (parts.length !== 2) {
|
if (parts.length !== 2) {
|
||||||
throw new Error('You can use || only once in `parseTitle`');
|
throw new Error('You can use || only once in `parseTitle`');
|
||||||
}
|
}
|
||||||
|
// remove || in titleParts
|
||||||
|
titleParts = titleParts.map(part => part.split('||')[0]).map(part => part.trim());
|
||||||
|
|
||||||
navigationTitle = navigationTitle.split('||').map(part => part.trim())[0];
|
navigationTitle = navigationTitle.split('||').map(part => part.trim())[0];
|
||||||
key = key.split('||').map(part => part.trim())[0];
|
key = key.split('||').map(part => part.trim())[0];
|
||||||
title = parts[0];
|
title = parts[0];
|
||||||
order = parseInt(parts[1]);
|
order = parseInt(parts[1]);
|
||||||
}
|
}
|
||||||
|
data.parts = titleParts;
|
||||||
data.title = title;
|
data.title = title;
|
||||||
data.eleventyNavigation = {
|
data.eleventyNavigation = {
|
||||||
key,
|
key,
|
||||||
|
|||||||
1
packages/core/src/title/types.d.ts
vendored
@@ -6,4 +6,5 @@ export interface EleventyPage {
|
|||||||
parent?: string;
|
parent?: string;
|
||||||
order?: number;
|
order?: number;
|
||||||
};
|
};
|
||||||
|
parts: string[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ describe('parseTitle', () => {
|
|||||||
key: 'heading',
|
key: 'heading',
|
||||||
order: 0,
|
order: 0,
|
||||||
},
|
},
|
||||||
|
parts: ['heading'],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -21,6 +22,7 @@ describe('parseTitle', () => {
|
|||||||
key: 'Foo >>',
|
key: 'Foo >>',
|
||||||
order: 0,
|
order: 0,
|
||||||
},
|
},
|
||||||
|
parts: ['Foo'],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -33,6 +35,7 @@ describe('parseTitle', () => {
|
|||||||
parent: 'Foo',
|
parent: 'Foo',
|
||||||
order: 0,
|
order: 0,
|
||||||
},
|
},
|
||||||
|
parts: ['Bar', 'Foo'],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -45,6 +48,7 @@ describe('parseTitle', () => {
|
|||||||
parent: 'Foo >> Bar',
|
parent: 'Foo >> Bar',
|
||||||
order: 0,
|
order: 0,
|
||||||
},
|
},
|
||||||
|
parts: ['Baz', 'Bar', 'Foo'],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -56,6 +60,7 @@ describe('parseTitle', () => {
|
|||||||
key: 'heading',
|
key: 'heading',
|
||||||
order: 4,
|
order: 4,
|
||||||
},
|
},
|
||||||
|
parts: ['heading'],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(parseTitle('Foo >> Bar >> Baz ||4')).to.deep.equal({
|
expect(parseTitle('Foo >> Bar >> Baz ||4')).to.deep.equal({
|
||||||
@@ -66,6 +71,7 @@ describe('parseTitle', () => {
|
|||||||
order: 4,
|
order: 4,
|
||||||
parent: 'Foo >> Bar',
|
parent: 'Foo >> Bar',
|
||||||
},
|
},
|
||||||
|
parts: ['Baz', 'Bar', 'Foo'],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @rocket/drawer
|
# @rocket/drawer
|
||||||
|
|
||||||
|
## 0.1.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 897892d: bump dependencies
|
||||||
|
|
||||||
## 0.1.1
|
## 0.1.1
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rocket/drawer",
|
"name": "@rocket/drawer",
|
||||||
"version": "0.1.1",
|
"version": "0.1.2",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
"testing"
|
"testing"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lion/overlays": "^0.22.8",
|
"@lion/overlays": "^0.23.2",
|
||||||
"lit-element": "^2.4.0"
|
"lit-element": "^2.4.0"
|
||||||
},
|
},
|
||||||
"types": "dist-types/index.d.ts"
|
"types": "dist-types/index.d.ts"
|
||||||
|
|||||||
@@ -1,6 +1,16 @@
|
|||||||
# @rocket/eleventy-plugin-mdjs-unified
|
# @rocket/eleventy-plugin-mdjs-unified
|
||||||
|
|
||||||
|
## 0.2.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- 4858271: **BREAKING CHANGES**: to support all 11ty templates
|
||||||
|
|
||||||
|
- returning html content directly instead of an object with html, js, stories
|
||||||
|
- no longer process relative links
|
||||||
|
|
||||||
## 0.1.0
|
## 0.1.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|
||||||
- 1971f5d: Initial Release
|
- 1971f5d: Initial Release
|
||||||
|
|||||||
@@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
Use mdjs in your 11ty site.
|
Use mdjs in your 11ty site.
|
||||||
|
|
||||||
For docs please see our homepage [https://rocket.modern-web.dev/docs/markdown-javascript/overview/](https://rocket.modern-web.dev/docs/markdown-javascript/overview/).
|
For docs please see our homepage [https://rocket.modern-web.dev/docs/eleventy-plugins/mdjs-unified/](https://rocket.modern-web.dev/docs/eleventy-plugins/mdjs-unified/).
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rocket/eleventy-plugin-mdjs-unified",
|
"name": "@rocket/eleventy-plugin-mdjs-unified",
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,61 +12,6 @@ const { parseTitle } = require('@rocket/core/title');
|
|||||||
/** @typedef {import('../types/code').NodeElement} NodeElement */
|
/** @typedef {import('../types/code').NodeElement} NodeElement */
|
||||||
/** @typedef {import('unist').Node} Node */
|
/** @typedef {import('unist').Node} Node */
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} link
|
|
||||||
*/
|
|
||||||
function isInternalLink(link) {
|
|
||||||
if (link.startsWith('http') || link.startsWith('/')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {*} pluginOptions
|
|
||||||
*/
|
|
||||||
function adjustLinks(pluginOptions) {
|
|
||||||
/**
|
|
||||||
* @param {NodeElement} node
|
|
||||||
*/
|
|
||||||
const elementVisitor = node => {
|
|
||||||
if (node.tagName === 'a') {
|
|
||||||
const fullHref = node.properties && node.properties.href ? node.properties.href : undefined;
|
|
||||||
if (fullHref) {
|
|
||||||
const [href, anchor] = fullHref.split('#');
|
|
||||||
const suffix = anchor ? `#${anchor}` : '';
|
|
||||||
const { inputPath } = pluginOptions.page;
|
|
||||||
|
|
||||||
if (isInternalLink(href) && href.endsWith('.md')) {
|
|
||||||
if (href.endsWith('index.md')) {
|
|
||||||
node.properties.href = `${href.substring(0, href.lastIndexOf('/') + 1)}${suffix}`;
|
|
||||||
} else {
|
|
||||||
node.properties.href = `${href.substring(0, href.length - 3)}/${suffix}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inputPath.endsWith('.md')) {
|
|
||||||
if (inputPath.endsWith('index.md')) {
|
|
||||||
// nothing
|
|
||||||
} else {
|
|
||||||
node.properties.href = `../${node.properties.href}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Node} tree
|
|
||||||
*/
|
|
||||||
function transformer(tree) {
|
|
||||||
visit(tree, 'element', elementVisitor);
|
|
||||||
return tree;
|
|
||||||
}
|
|
||||||
|
|
||||||
return transformer;
|
|
||||||
}
|
|
||||||
|
|
||||||
function cleanupTitleHeadline() {
|
function cleanupTitleHeadline() {
|
||||||
/**
|
/**
|
||||||
* @param {NodeChildren} node
|
* @param {NodeChildren} node
|
||||||
@@ -108,21 +53,6 @@ function addCleanupTitleHeadline(plugins) {
|
|||||||
return plugins;
|
return plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {MdjsProcessPlugin[]} plugins
|
|
||||||
*/
|
|
||||||
function addAdjustLinksForEleventy(plugins) {
|
|
||||||
if (plugins.findIndex(plugin => plugin.name === 'adjustLinks') === -1) {
|
|
||||||
// add plugins right after remark2rehype
|
|
||||||
const remark2rehypePluginIndex = plugins.findIndex(plugin => plugin.name === 'remark2rehype');
|
|
||||||
plugins.splice(remark2rehypePluginIndex + 1, 0, {
|
|
||||||
name: 'adjustLinks',
|
|
||||||
plugin: adjustLinks,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return plugins;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} source
|
* @param {string} source
|
||||||
* @param {string} inputPath
|
* @param {string} inputPath
|
||||||
@@ -196,7 +126,6 @@ function eleventyUnified(pluginOptions) {
|
|||||||
const result = await mdjsProcess(mdjs, {
|
const result = await mdjsProcess(mdjs, {
|
||||||
setupUnifiedPlugins: [
|
setupUnifiedPlugins: [
|
||||||
addCleanupTitleHeadline,
|
addCleanupTitleHeadline,
|
||||||
addAdjustLinksForEleventy,
|
|
||||||
...userSetupUnifiedPlugins,
|
...userSetupUnifiedPlugins,
|
||||||
addEleventyPageToEveryPlugin,
|
addEleventyPageToEveryPlugin,
|
||||||
],
|
],
|
||||||
@@ -204,7 +133,15 @@ function eleventyUnified(pluginOptions) {
|
|||||||
|
|
||||||
result.jsCode = await processImports(result.jsCode, eleventySettings.page.inputPath);
|
result.jsCode = await processImports(result.jsCode, eleventySettings.page.inputPath);
|
||||||
|
|
||||||
return result;
|
let code = result.html;
|
||||||
|
if (result.jsCode) {
|
||||||
|
code += `
|
||||||
|
<script type="module">
|
||||||
|
${result.jsCode}
|
||||||
|
</script>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
set: () => {
|
set: () => {
|
||||||
|
|||||||
@@ -44,12 +44,8 @@ describe('eleventy-plugin-mdjs-unified', () => {
|
|||||||
const files = await renderEleventy('./test-node/fixtures/md');
|
const files = await renderEleventy('./test-node/fixtures/md');
|
||||||
expect(files).to.deep.equal([
|
expect(files).to.deep.equal([
|
||||||
{
|
{
|
||||||
html: {
|
html:
|
||||||
stories: [],
|
'<h1 id="first"><a aria-hidden="true" tabindex="-1" href="#first"><span class="icon icon-link"></span></a>First</h1>',
|
||||||
jsCode: '',
|
|
||||||
html:
|
|
||||||
'<h1 id="first"><a aria-hidden="true" tabindex="-1" href="#first"><span class="icon icon-link"></span></a>First</h1>',
|
|
||||||
},
|
|
||||||
name: 'first/index.html',
|
name: 'first/index.html',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -59,26 +55,8 @@ describe('eleventy-plugin-mdjs-unified', () => {
|
|||||||
const files = await renderEleventy('./test-node/fixtures/mdjs');
|
const files = await renderEleventy('./test-node/fixtures/mdjs');
|
||||||
expect(files).to.deep.equal([
|
expect(files).to.deep.equal([
|
||||||
{
|
{
|
||||||
html: {
|
html:
|
||||||
html:
|
'<h1 id="first"><a aria-hidden="true" tabindex="-1" href="#first"><span class="icon icon-link"></span></a>First</h1>\n<pre class="language-js"><code class="language-js"><span class="token keyword">const</span> foo <span class="token operator">=</span> <span class="token string">\'bar\'</span><span class="token punctuation">;</span>\n<span class="token keyword module">import</span> <span class="token punctuation">{</span> html <span class="token punctuation">}</span> <span class="token keyword module">from</span> <span class="token string">\'lit-html\'</span><span class="token punctuation">;</span>\n</code></pre>\n<mdjs-story mdjs-story-name="inline"></mdjs-story>\n<mdjs-preview mdjs-story-name="withBorder"></mdjs-preview>\n <script type="module">\n \nexport const inline = () => html` <p>main</p> `;\nexport const withBorder = () => html` <p>main</p> `;\nconst rootNode = document;\nconst stories = [{ key: \'inline\', story: inline, code: `<pre class="language-js"><code class="language-js"><span class="token keyword module">export</span> <span class="token keyword">const</span> <span class="token function-variable function">inline</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> html<span class="token template-string"><span class="token template-punctuation string">\\`</span><span class="token html language-html"> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span>main<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span> </span><span class="token template-punctuation string">\\`</span></span><span class="token punctuation">;</span>\n</code></pre>` }, { key: \'withBorder\', story: withBorder, code: `<pre class="language-js"><code class="language-js"><span class="token keyword module">export</span> <span class="token keyword">const</span> <span class="token function-variable function">withBorder</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> html<span class="token template-string"><span class="token template-punctuation string">\\`</span><span class="token html language-html"> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span>main<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span> </span><span class="token template-punctuation string">\\`</span></span><span class="token punctuation">;</span>\n</code></pre>` }];\nfor (const story of stories) {\n const storyEl = rootNode.querySelector(`[mdjs-story-name="${story.key}"]`);\n storyEl.codeHasHtml = true;\n storyEl.story = story.story;\n storyEl.code = story.code;\n};\nif (!customElements.get(\'mdjs-preview\')) { import(\'@mdjs/mdjs-preview/mdjs-preview.js\'); }\nif (!customElements.get(\'mdjs-story\')) { import(\'@mdjs/mdjs-story/mdjs-story.js\'); }\n </script>\n ',
|
||||||
'<h1 id="first"><a aria-hidden="true" tabindex="-1" href="#first"><span class="icon icon-link"></span></a>First</h1>\n<pre class="language-js"><code class="language-js"><span class="token keyword">const</span> foo <span class="token operator">=</span> <span class="token string">\'bar\'</span><span class="token punctuation">;</span>\n<span class="token keyword module">import</span> <span class="token punctuation">{</span> html <span class="token punctuation">}</span> <span class="token keyword module">from</span> <span class="token string">\'lit-html\'</span><span class="token punctuation">;</span>\n</code></pre>\n<mdjs-story mdjs-story-name="inline"></mdjs-story>\n<mdjs-preview mdjs-story-name="withBorder"></mdjs-preview>',
|
|
||||||
jsCode:
|
|
||||||
'\nexport const inline = () => html` <p>main</p> `;\nexport const withBorder = () => html` <p>main</p> `;\nconst rootNode = document;\nconst stories = [{ key: \'inline\', story: inline, code: `<pre class="language-js"><code class="language-js"><span class="token keyword module">export</span> <span class="token keyword">const</span> <span class="token function-variable function">inline</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> html<span class="token template-string"><span class="token template-punctuation string">\\`</span><span class="token html language-html"> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span>main<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span> </span><span class="token template-punctuation string">\\`</span></span><span class="token punctuation">;</span>\n</code></pre>` }, { key: \'withBorder\', story: withBorder, code: `<pre class="language-js"><code class="language-js"><span class="token keyword module">export</span> <span class="token keyword">const</span> <span class="token function-variable function">withBorder</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> html<span class="token template-string"><span class="token template-punctuation string">\\`</span><span class="token html language-html"> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span>main<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span> </span><span class="token template-punctuation string">\\`</span></span><span class="token punctuation">;</span>\n</code></pre>` }];\nfor (const story of stories) {\n const storyEl = rootNode.querySelector(`[mdjs-story-name="${story.key}"]`);\n storyEl.codeHasHtml = true;\n storyEl.story = story.story;\n storyEl.code = story.code;\n};\nif (!customElements.get(\'mdjs-preview\')) { import(\'@mdjs/mdjs-preview/mdjs-preview.js\'); }\nif (!customElements.get(\'mdjs-story\')) { import(\'@mdjs/mdjs-story/mdjs-story.js\'); }',
|
|
||||||
stories: [
|
|
||||||
{
|
|
||||||
code: 'export const inline = () => html` <p>main</p> `;',
|
|
||||||
key: 'inline',
|
|
||||||
name: 'inline',
|
|
||||||
type: 'js',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
code: 'export const withBorder = () => html` <p>main</p> `;',
|
|
||||||
key: 'withBorder',
|
|
||||||
name: 'withBorder',
|
|
||||||
type: 'js',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
name: 'first/index.html',
|
name: 'first/index.html',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -88,11 +66,8 @@ describe('eleventy-plugin-mdjs-unified', () => {
|
|||||||
const files = await renderEleventy('./test-node/fixtures/mdjs-import');
|
const files = await renderEleventy('./test-node/fixtures/mdjs-import');
|
||||||
expect(files).to.deep.equal([
|
expect(files).to.deep.equal([
|
||||||
{
|
{
|
||||||
html: {
|
html:
|
||||||
html: '<p>first</p>',
|
"<p>first</p>\n <script type=\"module\">\n import '../import-me.js';\nimport('../import-me-too.js');\n </script>\n ",
|
||||||
jsCode: "import '../import-me.js';\nimport('../import-me-too.js');",
|
|
||||||
stories: [],
|
|
||||||
},
|
|
||||||
name: 'first/index.html',
|
name: 'first/index.html',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -102,11 +77,8 @@ describe('eleventy-plugin-mdjs-unified', () => {
|
|||||||
const files = await renderEleventy('./test-node/fixtures/mdjs-import-in-subpage');
|
const files = await renderEleventy('./test-node/fixtures/mdjs-import-in-subpage');
|
||||||
expect(files).to.deep.equal([
|
expect(files).to.deep.equal([
|
||||||
{
|
{
|
||||||
html: {
|
html:
|
||||||
html: '<p>first</p>',
|
"<p>first</p>\n <script type=\"module\">\n import '../../import-me.js';\nimport('../../import-me-too.js');\n </script>\n ",
|
||||||
jsCode: "import '../../import-me.js';\nimport('../../import-me-too.js');",
|
|
||||||
stories: [],
|
|
||||||
},
|
|
||||||
name: 'subpage/first/index.html',
|
name: 'subpage/first/index.html',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -116,62 +88,19 @@ describe('eleventy-plugin-mdjs-unified', () => {
|
|||||||
const files = await renderEleventy('./test-node/fixtures/mdjs-import-index');
|
const files = await renderEleventy('./test-node/fixtures/mdjs-import-index');
|
||||||
expect(files).to.deep.equal([
|
expect(files).to.deep.equal([
|
||||||
{
|
{
|
||||||
html: {
|
html:
|
||||||
html: '<p>index</p>',
|
"<p>index</p>\n <script type=\"module\">\n import './import-me.js';\nimport('./import-me-too.js');\n </script>\n ",
|
||||||
jsCode: "import './import-me.js';\nimport('./import-me-too.js');",
|
|
||||||
stories: [],
|
|
||||||
},
|
|
||||||
name: 'index.html',
|
name: 'index.html',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rewrites links to work with 11ty', async () => {
|
|
||||||
const files = await renderEleventy('./test-node/fixtures/links');
|
|
||||||
const sortedFiles = files.sort((a, b) => a.name.length - b.name.length);
|
|
||||||
expect(sortedFiles).to.deep.equal([
|
|
||||||
{
|
|
||||||
html: {
|
|
||||||
html: [
|
|
||||||
'<p><a href="./file/">file</a>',
|
|
||||||
'<a href="./folder/folderfile/">folder file</a>',
|
|
||||||
'<a href="./file/#my-anchor">file with my anchor</a>',
|
|
||||||
'<a href="./folder/folderfile/#my-anchor">folder file with my anchor</a></p>',
|
|
||||||
].join('\n'),
|
|
||||||
jsCode: '',
|
|
||||||
stories: [],
|
|
||||||
},
|
|
||||||
name: 'index.html',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
html: {
|
|
||||||
html: '<p>file</p>',
|
|
||||||
jsCode: '',
|
|
||||||
stories: [],
|
|
||||||
},
|
|
||||||
name: 'file/index.html',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
html: {
|
|
||||||
html: '<p>folder index file</p>',
|
|
||||||
jsCode: '',
|
|
||||||
stories: [],
|
|
||||||
},
|
|
||||||
name: 'folder/index.html',
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('allows to configure the plugins for unity', async () => {
|
it('allows to configure the plugins for unity', async () => {
|
||||||
const files = await renderEleventy('./test-node/fixtures/plugin-configure');
|
const files = await renderEleventy('./test-node/fixtures/plugin-configure');
|
||||||
expect(files).to.deep.equal([
|
expect(files).to.deep.equal([
|
||||||
{
|
{
|
||||||
html: {
|
html:
|
||||||
stories: [],
|
'<h1 id="first"><a class="anchor" href="#first"><span class="icon icon-link"></span></a>First</h1>',
|
||||||
jsCode: '',
|
|
||||||
html:
|
|
||||||
'<h1 id="first"><a class="anchor" href="#first"><span class="icon icon-link"></span></a>First</h1>',
|
|
||||||
},
|
|
||||||
name: 'first/index.html',
|
name: 'first/index.html',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -1,6 +1,19 @@
|
|||||||
# @rocket/eleventy-rocket-nav
|
# @rocket/eleventy-rocket-nav
|
||||||
|
|
||||||
|
## 0.2.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 897892d: bump dependencies
|
||||||
|
|
||||||
|
## 0.2.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- 4858271: Adjust templates for change in `@rocket/eleventy-plugin-mdjs-unified` as it now returns html directly instead of an object with html, js, stories
|
||||||
|
|
||||||
## 0.1.0
|
## 0.1.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|
||||||
- 1971f5d: Initial Release
|
- 1971f5d: Initial Release
|
||||||
|
|||||||
@@ -94,13 +94,10 @@ function findNavigationEntries(nodes = [], key = '') {
|
|||||||
entry.title = entry.key;
|
entry.title = entry.key;
|
||||||
}
|
}
|
||||||
if (entry.key) {
|
if (entry.key) {
|
||||||
if (!headingsCache.has(entry.templateContent.html)) {
|
if (!headingsCache.has(entry.templateContent)) {
|
||||||
headingsCache.set(
|
headingsCache.set(entry.templateContent, getHeadingsOfHtml(entry.templateContent));
|
||||||
entry.templateContent.html,
|
|
||||||
getHeadingsOfHtml(entry.templateContent.html),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
const headings = /** @type {Heading[]} */ (headingsCache.get(entry.templateContent.html));
|
const headings = /** @type {Heading[]} */ (headingsCache.get(entry.templateContent));
|
||||||
const anchors = headings.map(heading => ({
|
const anchors = headings.map(heading => ({
|
||||||
key: heading.text + Math.random(),
|
key: heading.text + Math.random(),
|
||||||
parent: entry.key,
|
parent: entry.key,
|
||||||
@@ -125,13 +122,10 @@ function findNavigationEntries(nodes = [], key = '') {
|
|||||||
function rocketPageAnchors(nodes, { title }) {
|
function rocketPageAnchors(nodes, { title }) {
|
||||||
for (const entry of nodes) {
|
for (const entry of nodes) {
|
||||||
if (entry.data && entry.data.title === title) {
|
if (entry.data && entry.data.title === title) {
|
||||||
if (!headingsCache.has(entry.templateContent.html)) {
|
if (!headingsCache.has(entry.templateContent)) {
|
||||||
headingsCache.set(
|
headingsCache.set(entry.templateContent, getHeadingsOfHtml(entry.templateContent));
|
||||||
entry.templateContent.html,
|
|
||||||
getHeadingsOfHtml(entry.templateContent.html),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
const headings = /** @type {Heading[]} */ (headingsCache.get(entry.templateContent.html));
|
const headings = /** @type {Heading[]} */ (headingsCache.get(entry.templateContent));
|
||||||
const anchors = headings.map(heading => ({
|
const anchors = headings.map(heading => ({
|
||||||
key: heading.text + Math.random(),
|
key: heading.text + Math.random(),
|
||||||
parent: entry.key,
|
parent: entry.key,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rocket/eleventy-rocket-nav",
|
"name": "@rocket/eleventy-rocket-nav",
|
||||||
"version": "0.1.0",
|
"version": "0.2.1",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
"eleventy-plugin"
|
"eleventy-plugin"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dependency-graph": "^0.9.0",
|
"dependency-graph": "^0.10.0",
|
||||||
"sax-wasm": "^2.0.0"
|
"sax-wasm": "^2.0.0"
|
||||||
},
|
},
|
||||||
"types": "dist-types/index.d.ts"
|
"types": "dist-types/index.d.ts"
|
||||||
|
|||||||
4
packages/eleventy-rocket-nav/types.d.ts
vendored
@@ -4,9 +4,7 @@ export interface NavigationNode {
|
|||||||
key: string;
|
key: string;
|
||||||
url: string;
|
url: string;
|
||||||
pluginType?: string;
|
pluginType?: string;
|
||||||
templateContent: {
|
templateContent: string;
|
||||||
html: string;
|
|
||||||
};
|
|
||||||
data?: {
|
data?: {
|
||||||
title: string;
|
title: string;
|
||||||
page: {
|
page: {
|
||||||
|
|||||||
@@ -1,5 +1,25 @@
|
|||||||
# @rocket/launch
|
# @rocket/launch
|
||||||
|
|
||||||
|
## 0.2.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 86c3a4b: adds themable CSS custom properties to <inline-notification>
|
||||||
|
- 7dd6f4c: Make default logo work with auto generating social media images
|
||||||
|
- Updated dependencies [897892d]
|
||||||
|
- @rocket/drawer@0.1.2
|
||||||
|
|
||||||
|
## 0.2.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- ef3b846: Add a default "core" preset to the cli package which provides fundaments like eleventConfig data, eleventyComputed data, logo, site name, simple layout, ...
|
||||||
|
- 4858271: Adjust templates for change in `@rocket/eleventy-plugin-mdjs-unified` as it now returns html directly instead of an object with html, js, stories
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 25adb74: feat(launch): add icons for discord and telegram
|
||||||
|
|
||||||
## 0.1.2
|
## 0.1.2
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -31,26 +31,29 @@ export class InlineNotification extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
:host([type='tip']) {
|
:host([type='tip']) {
|
||||||
background-color: rgba(221, 221, 221, 0.3);
|
background-color: var(--inline-notification-tip-background-color, rgba(221, 221, 221, 0.3));
|
||||||
border-color: #42b983;
|
border-color: var(--inline-notification-tip-border-color, #42b983);
|
||||||
}
|
}
|
||||||
|
|
||||||
:host([type='warning']) {
|
:host([type='warning']) {
|
||||||
background-color: rgba(255, 229, 100, 0.2);
|
background-color: var(
|
||||||
border-color: #e7c000;
|
--inline-notification-warning-background-color,
|
||||||
}
|
rgba(255, 229, 100, 0.2)
|
||||||
|
);
|
||||||
:host([type='warning']) h3 {
|
border-color: var(--inline-notification-warning-border-color, #e7c000);
|
||||||
color: #b29400;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:host([type='danger']) {
|
:host([type='danger']) {
|
||||||
background-color: rgba(192, 0, 0, 0.1);
|
background-color: var(--inline-notification-danger-background-color, rgba(192, 0, 0, 0.1));
|
||||||
border-color: #c00;
|
border-color: var(--inline-notification-danger-border-color, #c00);
|
||||||
|
}
|
||||||
|
|
||||||
|
:host([type='warning']) h3 {
|
||||||
|
color: var(--inline-notification-warning-heading-color, #b29400);
|
||||||
}
|
}
|
||||||
|
|
||||||
:host([type='danger']) h3 {
|
:host([type='danger']) h3 {
|
||||||
color: #900;
|
color: var(--inline-notification-danger-heading-color, #900);
|
||||||
}
|
}
|
||||||
|
|
||||||
::slotted(p) {
|
::slotted(p) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rocket/launch",
|
"name": "@rocket/launch",
|
||||||
"version": "0.1.2",
|
"version": "0.2.1",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
"preset"
|
"preset"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rocket/drawer": "^0.1.1",
|
"@rocket/drawer": "^0.1.2",
|
||||||
"@rocket/navigation": "^0.1.0"
|
"@rocket/navigation": "^0.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
packages/launch/preset/_assets/brand-logos/discord.svg
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="currentColor">
|
||||||
|
<title>Discord</title>
|
||||||
|
<path
|
||||||
|
d="m3.58 21.196h14.259l-.681-2.205 1.629 1.398 1.493 1.338 2.72 2.273v-21.525c-.068-1.338-1.22-2.475-2.648-2.475l-16.767.003c-1.427 0-2.585 1.139-2.585 2.477v16.24c0 1.411 1.156 2.476 2.58 2.476zm10.548-15.513-.033.012.012-.012zm-7.631 1.269c1.833-1.334 3.532-1.27 3.532-1.27l.137.135c-2.243.535-3.26 1.537-3.26 1.537s.272-.133.747-.336c3.021-1.188 6.32-1.102 9.374.402 0 0-1.019-.937-3.124-1.537l.186-.183c.291.001 1.831.055 3.479 1.26 0 0 1.844 3.15 1.844 7.02-.061-.074-1.144 1.666-3.931 1.726 0 0-.472-.534-.808-1 1.63-.468 2.24-1.404 2.24-1.404-.535.337-1.023.537-1.419.737-.609.268-1.219.4-1.828.535-2.884.468-4.503-.315-6.033-.936l-.523-.266s.609.936 2.174 1.404c-.411.469-.818 1.002-.818 1.002-2.786-.066-3.802-1.806-3.802-1.806 0-3.876 1.833-7.02 1.833-7.02z"></path>
|
||||||
|
<path d="m14.308 12.771c.711 0 1.29-.6 1.29-1.34 0-.735-.576-1.335-1.29-1.335v.003c-.708 0-1.288.598-1.29 1.338 0 .734.579 1.334 1.29 1.334z"></path>
|
||||||
|
<path d="m9.69 12.771c.711 0 1.29-.6 1.29-1.34 0-.735-.575-1.335-1.286-1.335l-.004.003c-.711 0-1.29.598-1.29 1.338 0 .734.579 1.334 1.29 1.334z"></path>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.2 KiB |
4
packages/launch/preset/_assets/brand-logos/telegram.svg
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 54 54" fill="currentColor">
|
||||||
|
<path d="M-.2.1h53.8v53.4H-.2z" fill="none"/>
|
||||||
|
<path d="M49.7 16.5c1.3 3.1 2 6.3 2 9.7s-.7 6.6-2 9.7c-1.3 3.1-3.1 5.7-5.3 8-2.2 2.2-4.9 4-8 5.3-3.1 1.3-6.3 2-9.7 2-3.4 0-6.6-.7-9.7-2s-5.7-3.1-8-5.3c-2.2-2.2-4-4.9-5.3-8-1.3-3.1-2-6.3-2-9.7s.7-6.6 2-9.7c1.3-3.1 3.1-5.7 5.3-8 2.2-2.2 4.9-4 8-5.3s6.3-2 9.7-2c3.4 0 6.6.7 9.7 2 3.1 1.3 5.7 3.1 8 5.3 2.2 2.3 3.9 5 5.3 8zM34.8 37.7l4.1-19.3c.2-.8.1-1.4-.3-1.8-.4-.4-.8-.4-1.4-.2l-24.1 9.3c-.5.2-.9.4-1.1.7-.2.3-.2.5-.1.7.1.2.4.4.9.5l6.2 1.9 14.3-9c.4-.3.7-.3.9-.2.1.1.1.2-.1.4L22.5 31.3l-.5 6.4c.4 0 .8-.2 1.3-.6l3-2.9 6.2 4.6c1.3.7 2 .3 2.3-1.1z"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 686 B |
@@ -1,5 +1,3 @@
|
|||||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
||||||
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
||||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
viewBox="0 0 511.998 511.998" style="enable-background:new 0 0 511.998 511.998;" xml:space="preserve">
|
viewBox="0 0 511.998 511.998" style="enable-background:new 0 0 511.998 511.998;" xml:space="preserve">
|
||||||
<g>
|
<g>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.6 KiB |
@@ -466,6 +466,7 @@
|
|||||||
/* background-color: #fff; */
|
/* background-color: #fff; */
|
||||||
box-sizing: content-box;
|
box-sizing: content-box;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.markdown-body img[align='right'] {
|
.markdown-body img[align='right'] {
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
const { getComputedConfig } = require('@rocket/cli');
|
|
||||||
|
|
||||||
module.exports = getComputedConfig();
|
|
||||||
@@ -17,6 +17,5 @@ module.exports = function () {
|
|||||||
iconColorMaskIcon: '#3f93ce',
|
iconColorMaskIcon: '#3f93ce',
|
||||||
iconColorMsapplicationTileColor: '#1d3557',
|
iconColorMsapplicationTileColor: '#1d3557',
|
||||||
iconColorThemeColor: '#1d3557',
|
iconColorThemeColor: '#1d3557',
|
||||||
socialMediaImage: '/_assets/social-media-image.jpg',
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{{ content.html | safe }}
|
{{ content | safe }}
|
||||||
{% include 'partials/previousNext.njk' %}
|
{% include 'partials/previousNext.njk' %}
|
||||||
</main>
|
</main>
|
||||||
{% endblock main %}
|
{% endblock main %}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
{% block sidebar %}{% endblock sidebar %}
|
{% block sidebar %}{% endblock sidebar %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
{{ content.html | safe }}
|
{{ content | safe }}
|
||||||
{% endblock main %}
|
{% endblock main %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -26,11 +26,7 @@
|
|||||||
<meta property="og:title" content="{{ _pageTitle }}"/>
|
<meta property="og:title" content="{{ _pageTitle }}"/>
|
||||||
<meta property="og:type" content="website"/>
|
<meta property="og:type" content="website"/>
|
||||||
|
|
||||||
{% set _socialMediaImage = '/_assets/social-media-image.jpg' | asset %}
|
<meta property="og:image" content="{{ socialMediaImage }}"/>
|
||||||
{% if socialMediaImage %}
|
|
||||||
{% set _socialMediaImage = socialMediaImage %}
|
|
||||||
{% endif %}
|
|
||||||
<meta property="og:image" content="{{ _socialMediaImage | url }}"/>
|
|
||||||
<meta property="og:url" content="{{ page.url }}"/>
|
<meta property="og:url" content="{{ page.url }}"/>
|
||||||
|
|
||||||
<meta name="twitter:card" content="summary_large_image"/>
|
<meta name="twitter:card" content="summary_large_image"/>
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
{% if content.jsCode %}
|
|
||||||
<script type="module">
|
|
||||||
{{ content.jsCode | safe }}
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if site.analytics %}
|
{% if site.analytics %}
|
||||||
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.analytics }}"></script>
|
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.analytics }}"></script>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<main class="markdown-body">
|
<main class="markdown-body">
|
||||||
{% include 'partials/addTitleHeadline.njk' %}
|
{% include 'partials/addTitleHeadline.njk' %}
|
||||||
|
|
||||||
{{ content.html | safe }}
|
{{ content | safe }}
|
||||||
|
|
||||||
<h3>Find out more on the following pages:</h3>
|
<h3>Find out more on the following pages:</h3>
|
||||||
{{ collections[section] | rocketNav(eleventyNavigation.key) | rocketNavToHtml({
|
{{ collections[section] | rocketNav(eleventyNavigation.key) | rocketNavToHtml({
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
<main class="markdown-body">
|
<main class="markdown-body">
|
||||||
{% include 'partials/addTitleHeadline.njk' %}
|
{% include 'partials/addTitleHeadline.njk' %}
|
||||||
|
|
||||||
{{ content.html | safe }}
|
{{ content | safe }}
|
||||||
|
|
||||||
{% include 'partials/previousNext.njk' %}
|
{% include 'partials/previousNext.njk' %}
|
||||||
{% include 'partials/content-footer.njk' %}
|
{% include 'partials/content-footer.njk' %}
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## 0.6.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 897892d: bump dependencies
|
||||||
|
- b68923b: Add gfm to support markdown tables
|
||||||
|
|
||||||
## 0.6.1
|
## 0.6.1
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mdjs/core",
|
"name": "@mdjs/core",
|
||||||
"version": "0.6.1",
|
"version": "0.6.2",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -54,10 +54,11 @@
|
|||||||
"rehype-raw": "^5.0.0",
|
"rehype-raw": "^5.0.0",
|
||||||
"rehype-slug": "^4.0.1",
|
"rehype-slug": "^4.0.1",
|
||||||
"rehype-stringify": "^8.0.0",
|
"rehype-stringify": "^8.0.0",
|
||||||
"remark": "^11.0.2",
|
"remark": "^13.0.0",
|
||||||
|
"remark-gfm": "^1.0.0",
|
||||||
"remark-parse": "^9.0.0",
|
"remark-parse": "^9.0.0",
|
||||||
"remark-rehype": "^8.0.0",
|
"remark-rehype": "^8.0.0",
|
||||||
"unified": "^8.4.2",
|
"unified": "^9.2.0",
|
||||||
"unist-util-remove": "^2.0.1",
|
"unist-util-remove": "^2.0.1",
|
||||||
"unist-util-visit": "^2.0.3"
|
"unist-util-visit": "^2.0.3"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
const unified = require('unified');
|
const unified = require('unified');
|
||||||
const markdown = require('remark-parse');
|
const markdown = require('remark-parse');
|
||||||
|
const gfm = require('remark-gfm');
|
||||||
const remark2rehype = require('remark-rehype');
|
const remark2rehype = require('remark-rehype');
|
||||||
const raw = require('rehype-raw');
|
const raw = require('rehype-raw');
|
||||||
const htmlStringify = require('rehype-stringify');
|
const htmlStringify = require('rehype-stringify');
|
||||||
@@ -21,6 +22,7 @@ const { mdjsStoryParse } = require('./mdjsStoryParse.js');
|
|||||||
/** @type {MdjsProcessPlugin[]} */
|
/** @type {MdjsProcessPlugin[]} */
|
||||||
const defaultMetaPlugins = [
|
const defaultMetaPlugins = [
|
||||||
{ name: 'markdown', plugin: markdown },
|
{ name: 'markdown', plugin: markdown },
|
||||||
|
{ name: 'gfm', plugin: gfm },
|
||||||
{ name: 'mdjsParse', plugin: mdjsParse },
|
{ name: 'mdjsParse', plugin: mdjsParse },
|
||||||
{ name: 'mdjsStoryParse', plugin: mdjsStoryParse },
|
{ name: 'mdjsStoryParse', plugin: mdjsStoryParse },
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|||||||
@@ -136,4 +136,18 @@ describe('mdjsProcess', () => {
|
|||||||
});
|
});
|
||||||
expect(resultOfArray.html).to.equal(expectedForArray);
|
expect(resultOfArray.html).to.equal(expectedForArray);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('handles tables', async () => {
|
||||||
|
const input = [
|
||||||
|
//
|
||||||
|
'| Page | Type |',
|
||||||
|
'| ----- | ---- |',
|
||||||
|
'| About | Info |',
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
|
const expected =
|
||||||
|
'<table><thead><tr><th>Page</th><th>Type</th></tr></thead><tbody><tr><td>About</td><td>Info</td></tr></tbody></table>';
|
||||||
|
const result = await mdjsProcess(input);
|
||||||
|
expect(result.html.trim()).to.equal(expected);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,17 @@
|
|||||||
# @rocket/search
|
# @rocket/search
|
||||||
|
|
||||||
|
## 0.1.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 897892d: bump dependencies
|
||||||
|
- 7b2dc64: fix(search): improve a11y
|
||||||
|
|
||||||
|
- a11y: add labels to button
|
||||||
|
- ux: replace 'arrow-left' icon with 'x' icon for 'close search' button
|
||||||
|
- perf: makes all templates static
|
||||||
|
- fix: address typescript errors
|
||||||
|
|
||||||
## 0.1.1
|
## 0.1.1
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rocket/search",
|
"name": "@rocket/search",
|
||||||
"version": "0.1.1",
|
"version": "0.1.2",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
"search"
|
"search"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lion/combobox": "^0.1.16",
|
"@lion/combobox": "^0.1.20",
|
||||||
"@open-wc/scoped-elements": "^1.3.2",
|
"@open-wc/scoped-elements": "^1.3.2",
|
||||||
"minisearch": "^3.0.2",
|
"minisearch": "^3.0.2",
|
||||||
"plugins-manager": "^0.2.0",
|
"plugins-manager": "^0.2.0",
|
||||||
|
|||||||