mirror of
https://github.com/modernweb-dev/rocket.git
synced 2026-04-02 00:41:20 +00:00
Compare commits
4 Commits
@rocket/cl
...
check-html
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45cd7206f1 | ||
|
|
eb74110dd8 | ||
|
|
517c7780ab | ||
|
|
e4852db673 |
@@ -1,7 +1,106 @@
|
|||||||
# Presets >> Create your own || 90
|
# Presets >> Create your own || 90
|
||||||
|
|
||||||
All loaded presets will be combined but you can override each file.
|
A preset is setup function and a folder including `_assets`, `_data` and `_includes` (all optional).
|
||||||
|
|
||||||
Take a look at `docs/_merged_includes` and override what you want to override by placing the same filename into `_includes`.
|
To play around with a preset you can create a folder `fire-theme`.
|
||||||
|
|
||||||
Also works for `_assets`, `_data` ...
|
You then create the setup function for it with only one property called `path` which will allow Rocket to properly resolve it.
|
||||||
|
|
||||||
|
## Create a Preset Config File
|
||||||
|
|
||||||
|
👉 `fire-theme/fireTheme.js`
|
||||||
|
|
||||||
|
```js
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
|
export function fireTheme() {
|
||||||
|
return {
|
||||||
|
path: path.resolve(__dirname),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Once you have that you can start filling in content you need.
|
||||||
|
|
||||||
|
For example a we could override the full `layout.css` by adding a it like so
|
||||||
|
|
||||||
|
👉 `fire-theme/layout.css`
|
||||||
|
|
||||||
|
```css
|
||||||
|
body {
|
||||||
|
background: hotpink;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Once you have that you can add it to your Rocket Config.
|
||||||
|
|
||||||
|
NOTE: The order of presets is important, as for example in this case we take everything from `rocketLaunch` but later override via `fireTheme`.
|
||||||
|
|
||||||
|
👉 `rocket-config.js`
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { rocketLaunch } from '@rocket/launch';
|
||||||
|
import { fireTheme } from 'path/to/fire-theme/fireTheme.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
presets: [rocketLaunch(), fireTheme()],
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
## Publish a preset
|
||||||
|
|
||||||
|
If you would like to publish a preset to use it on multiple websites or share it with your friends you can do like so.
|
||||||
|
|
||||||
|
1. Pick a name for the package => for this example we take `fire-theme`.
|
||||||
|
2. Create a new folder `fire-theme`
|
||||||
|
3. Create a folder `fire-theme/preset` copy `fireTheme.js` from [above](#create-a-preset-config-file) into `preset/fireTheme.js`
|
||||||
|
4. Add a 👉 `package.json`
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"name": "fire-theme",
|
||||||
|
"version": "0.3.0",
|
||||||
|
"description": "Fire Theme for Rocket",
|
||||||
|
"license": "MIT",
|
||||||
|
"type": "module",
|
||||||
|
"exports": {
|
||||||
|
".": "./index.js",
|
||||||
|
"./preset/": "./preset/"
|
||||||
|
},
|
||||||
|
"files": ["*.js", "preset"],
|
||||||
|
"keywords": ["rocket", "preset"]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Add a 👉 `index.js`
|
||||||
|
|
||||||
|
```js
|
||||||
|
export { fireTheme } from './preset/fireTheme.js';
|
||||||
|
```
|
||||||
|
|
||||||
|
6. Add a 👉 `README.md`
|
||||||
|
|
||||||
|
````
|
||||||
|
# FireTheme
|
||||||
|
|
||||||
|
This is a theme/preset for [Rocket](https://rocket.modern-web.dev/).
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```
|
||||||
|
npm i -D fire-theme
|
||||||
|
```
|
||||||
|
|
||||||
|
Add it to your 👉 `rocket.config.js`
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { fireTheme } from 'fire-theme';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
presets: [fireTheme()],
|
||||||
|
};
|
||||||
|
```
|
||||||
|
````
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
# check-html-links
|
# check-html-links
|
||||||
|
|
||||||
|
## 0.1.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- eb74110: Add info about how many files and links will be checked
|
||||||
|
|
||||||
## 0.1.0
|
## 0.1.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|
||||||
- cd22231: Initial release
|
- cd22231: Initial release
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ npx check-html-links _site
|
|||||||
|
|
||||||
For docs please see our homepage [https://rocket.modern-web.dev/docs/tools/check-html-links/](https://rocket.modern-web.dev/docs/tools/check-html-links/).
|
For docs please see our homepage [https://rocket.modern-web.dev/docs/tools/check-html-links/](https://rocket.modern-web.dev/docs/tools/check-html-links/).
|
||||||
|
|
||||||
## Comparision
|
## Comparison
|
||||||
|
|
||||||
Checking the output of [11ty-website](https://github.com/11ty/11ty-website) with 13 missing reference targets (used by 516 links) while checking 501 files. (on January 17, 2021)
|
Checking the output of [11ty-website](https://github.com/11ty/11ty-website) with 13 missing reference targets (used by 516 links) while checking 501 files. (on January 17, 2021)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "check-html-links",
|
"name": "check-html-links",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -13,7 +13,17 @@ async function main() {
|
|||||||
|
|
||||||
console.log('👀 Checking if all internal links work...');
|
console.log('👀 Checking if all internal links work...');
|
||||||
const files = await listFiles('**/*.html', rootDir);
|
const files = await listFiles('**/*.html', rootDir);
|
||||||
const errors = await validateFiles(files, rootDir);
|
|
||||||
|
const filesOutput =
|
||||||
|
files.length == 0
|
||||||
|
? '🧐 No files to check. Did you select the correct folder?'
|
||||||
|
: `🔥 Found a total of ${chalk.green.bold(files.length)} files to check!`;
|
||||||
|
console.log(filesOutput);
|
||||||
|
|
||||||
|
const { errors, numberLinks } = await validateFiles(files, rootDir);
|
||||||
|
|
||||||
|
console.log(`🔗 Found a total of ${chalk.green.bold(numberLinks)} links to validate!\n`);
|
||||||
|
|
||||||
const performance = process.hrtime(performanceStart);
|
const performance = process.hrtime(performanceStart);
|
||||||
if (errors.length > 0) {
|
if (errors.length > 0) {
|
||||||
let referenceCount = 0;
|
let referenceCount = 0;
|
||||||
|
|||||||
@@ -267,13 +267,15 @@ export async function validateFiles(files, rootDir) {
|
|||||||
errors = [];
|
errors = [];
|
||||||
checkLocalFiles = [];
|
checkLocalFiles = [];
|
||||||
idCache = new Map();
|
idCache = new Map();
|
||||||
|
let numberLinks = 0;
|
||||||
for (const htmlFilePath of files) {
|
for (const htmlFilePath of files) {
|
||||||
const { links } = await extractReferences(htmlFilePath);
|
const { links } = await extractReferences(htmlFilePath);
|
||||||
|
numberLinks += links.length;
|
||||||
await resolveLinks(links, { htmlFilePath, rootDir });
|
await resolveLinks(links, { htmlFilePath, rootDir });
|
||||||
}
|
}
|
||||||
await validateLocalFiles(checkLocalFiles);
|
await validateLocalFiles(checkLocalFiles);
|
||||||
|
|
||||||
return errors;
|
return { errors: errors, numberLinks: numberLinks };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -282,6 +284,6 @@ export async function validateFiles(files, rootDir) {
|
|||||||
export async function validateFolder(inRootDir) {
|
export async function validateFolder(inRootDir) {
|
||||||
const rootDir = path.resolve(inRootDir);
|
const rootDir = path.resolve(inRootDir);
|
||||||
const files = await listFiles('**/*.html', rootDir);
|
const files = await listFiles('**/*.html', rootDir);
|
||||||
const errors = await validateFiles(files, rootDir);
|
const { errors } = await validateFiles(files, rootDir);
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user