Skip to content

Commit 1a989f6

Browse files
feat: adjust site for standalone deployment
1 parent 9318d32 commit 1a989f6

13 files changed

Lines changed: 6385 additions & 48 deletions

.eleventy.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
"use strict";
2+
3+
module.exports = function (eleventyConfig) {
4+
eleventyConfig.addPlugin(
5+
require("@11ty/eleventy-plugin-inclusive-language"),
6+
{
7+
words:
8+
"simply,obviously,basically,of course,clearly,everyone knows,however,easy",
9+
},
10+
);
11+
12+
eleventyConfig.addPassthroughCopy("css");
13+
eleventyConfig.addPassthroughCopy("js");
14+
eleventyConfig.addPassthroughCopy("images");
15+
eleventyConfig.addPassthroughCopy("CNAME");
16+
eleventyConfig.addPassthroughCopy("_headers");
17+
eleventyConfig.addPassthroughCopy("favicon.ico");
18+
eleventyConfig.addPassthroughCopy("example");
19+
eleventyConfig.addPassthroughCopy("api/images");
20+
eleventyConfig.addPassthroughCopy("api/scripts");
21+
eleventyConfig.addPassthroughCopy("api/styles");
22+
23+
/* Markdown Plugins */
24+
const markdown = require("markdown-it")({
25+
html: true,
26+
linkify: true,
27+
typographer: true,
28+
});
29+
30+
markdown.use(require("markdown-it-anchor"), {
31+
slugify: require("uslug"),
32+
permalink: true,
33+
permalinkBefore: true,
34+
permalinkClass: "direct-link",
35+
permalinkSymbol: "#",
36+
});
37+
38+
markdown.use(require("markdown-it-attrs"), {
39+
leftDelimiter: "{:",
40+
rightDelimiter: "}",
41+
});
42+
43+
markdown.use(require("markdown-it-prism"));
44+
45+
markdown.use(require("markdown-it-emoji"));
46+
47+
eleventyConfig.setLibrary("md", markdown);
48+
49+
eleventyConfig.setUseGitIgnore(false);
50+
51+
return {
52+
passthroughFileCopy: true,
53+
dir: {
54+
input: ".",
55+
output: "_site",
56+
},
57+
};
58+
};

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
_site
2+
api
3+
images/supporters
4+
node_modules

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/_site/
2+
/api/
3+
/css/normalize.css
4+
/css/prism.css
5+
/js/

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2011-2024 OpenJS Foundation and contributors, https://openjsf.org
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
'Software'), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
# mochajs.org
22

3-
These are the docs for the classic version of mochajs.org. For the Astro site released in 2025, see docs-next.
4-
5-
The classic [mochajs.org](https://mochajs.org) is built using [Eleventy](https://www.11ty.io/), a simple static site generator.
3+
These are the legacy docs for Mocha built using [Eleventy](https://www.11ty.io/), a simple static site generator.
4+
They used to be served on [mochajs.org](https://mochajs.org); now they're served on [legacy.mochajs.org](https://legacy.mochajs.org).
65

76
## Development
87

9-
1. Run `npm install` / `npm ci` from working copy root to get Node.js deps.
10-
1. To include the API documentation, run `npm run docs:api` before the either of the following commands.
11-
1. To serve the site and rebuild as changes are made, run `npm run docs-watch`.
12-
1. To rebuild the site _once_, run `npm run docs`. This also builds the Astro site.
13-
1. To preview the site, run `npm run docs:preview`. The Astro site is available at `/next`.
8+
1. Run `npm install` from working copy root to get Node.js deps.
9+
1. To include the API documentation, run `npm run api` before the either of the following commands.
10+
1. To serve the site and rebuild as changes are made, run `npm run watch`.
11+
1. To rebuild the site _once_, run `npm run docs`.
12+
1. To preview the site, run `npm run preview`.
1413

1514
### Notes
1615

17-
- The content lives in `docs/index.md`; everything else is markup, scripts, assets, etc.
18-
- This file (`docs/README.md`) should _not_ be included in the build.
19-
- `docs/_site_` is where the deployed site lives. This directory is _not_ under version control.
16+
- The content lives in `index.md`; everything else is markup, scripts, assets, etc.
17+
- This file (`README.md`) should _not_ be included in the build.
18+
- `_site_` is where the deployed site lives. This directory is _not_ under version control.

_data/files.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ const { promises: fs } = require("node:fs");
55

66
const PROJECT_ROOT_DIR = resolve(__dirname, "..", "..");
77
const FILES = [
8-
{
9-
slug: "simplereporter",
10-
path: require.resolve("../../test/integration/fixtures/simple-reporter.js"),
11-
header: "// my-reporter.js",
12-
},
8+
// {
9+
// slug: "simplereporter",
10+
// path: require.resolve("../../test/integration/fixtures/simple-reporter.js"),
11+
// header: "// my-reporter.js",
12+
// },
1313
];
1414

1515
const loadFile = async (path, { header } = {}) => {

_data/supporters.js

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -100,31 +100,31 @@ const nodeToSupporter = (node) => ({
100100

101101
const fetchImage = process.env.MOCHA_DOCS_SKIP_IMAGE_DOWNLOAD
102102
? async (supporter) => {
103-
invalidSupporters.push(supporter);
104-
}
103+
invalidSupporters.push(supporter);
104+
}
105105
: async (supporter) => {
106-
try {
107-
const { avatar: url } = supporter;
108-
const { body: imageBuf, headers } = await needle("get", url, {
109-
open_timeout: 30000,
110-
});
111-
if (headers["content-type"].startsWith("text/html")) {
112-
throw new TypeError(
113-
"received html and expected a png; outage likely",
114-
);
115-
}
116-
debug("fetched %s", url);
117-
const filePath = resolve(SUPPORTER_IMAGE_PATH, supporter.id + ".png");
118-
await writeFile(filePath, imageBuf);
119-
debug("wrote %s", filePath);
120-
} catch (err) {
121-
console.error(
122-
`failed to load ${supporter.avatar}; will discard ${supporter.tier} "${supporter.name} (${supporter.slug}). reason:\n`,
123-
err,
106+
try {
107+
const { avatar: url } = supporter;
108+
const { body: imageBuf, headers } = await needle("get", url, {
109+
open_timeout: 30000,
110+
});
111+
if (headers["content-type"].startsWith("text/html")) {
112+
throw new TypeError(
113+
"received html and expected a png; outage likely",
124114
);
125-
invalidSupporters.push(supporter);
126115
}
127-
};
116+
debug("fetched %s", url);
117+
const filePath = resolve(SUPPORTER_IMAGE_PATH, supporter.id + ".png");
118+
await writeFile(filePath, imageBuf);
119+
debug("wrote %s", filePath);
120+
} catch (err) {
121+
console.error(
122+
`failed to load ${supporter.avatar}; will discard ${supporter.tier} "${supporter.name} (${supporter.slug}). reason:\n`,
123+
err,
124+
);
125+
invalidSupporters.push(supporter);
126+
}
127+
};
128128

129129
/**
130130
* Retrieves donation data from OC
@@ -266,18 +266,14 @@ const getSupporters = async () => {
266266
if (successRate < PRODUCTION_SUCCESS_THRESHOLD) {
267267
if (process.env.NETLIFY && process.env.CONTEXT !== "deploy-preview") {
268268
throw new Error(
269-
`Failed to meet success threshold ${
270-
PRODUCTION_SUCCESS_THRESHOLD * 100
271-
}% (was ${
272-
successRate * 100
269+
`Failed to meet success threshold ${PRODUCTION_SUCCESS_THRESHOLD * 100
270+
}% (was ${successRate * 100
273271
}%) for a production deployment; refusing to deploy`,
274272
);
275273
} else {
276274
console.warn(
277-
`WARNING: Success rate of ${
278-
successRate * 100
279-
}% fails to meet production threshold of ${
280-
PRODUCTION_SUCCESS_THRESHOLD * 100
275+
`WARNING: Success rate of ${successRate * 100
276+
}% fails to meet production threshold of ${PRODUCTION_SUCCESS_THRESHOLD * 100
281277
}%; would fail a production deployment!`,
282278
);
283279
}

_data/usage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { stripVTControlCharacters } = require("node:util");
44
const { resolve } = require("node:path");
55
const { execSync } = require("node:child_process");
66

7-
const executable = require.resolve("../../bin/mocha");
7+
const executable = require.resolve("mocha");
88
const flag = "--help";
99

1010
/**

index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: "Mocha is a feature-rich JavaScript test framework running on Node.
77
<!-- Disable MD051 due to the rule not aware of this file is specifically converted to HTML -->
88
<!--markdownlint-disable-file MD051 -->
99

10-
<div class="admonition">This site has a new look, try it out at <a href="next">mochajs.org/next</a>!</div>
10+
<div class="admonition">This site has a new look, try it out at <a href="https://mochajs.org">mochajs.org</a>!</div>
1111

1212
Mocha is a feature-rich JavaScript test framework running on [Node.js][] and in the browser, making asynchronous testing _simple_ and _fun_. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases. Hosted on [GitHub][github-mocha].
1313

jsdoc.conf.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"markdown": {
3+
"hardwrap": true,
4+
"parser": "gfm"
5+
},
6+
"mocha-docdash": {
7+
"sort": true,
8+
"static": false
9+
},
10+
"opts": {
11+
"destination": "api",
12+
"encoding": "utf8",
13+
"recurse": true,
14+
"template": "node_modules/@mocha/docdash",
15+
"tutorials": "api-tutorials",
16+
"verbose": true
17+
},
18+
"plugins": ["./node_modules/jsdoc-ts-utils", "plugins/markdown"],
19+
"source": {
20+
"include": ["node_modules/mocha/lib/", "./API.md", "node_modules/mocha/bin"]
21+
},
22+
"tags": {
23+
"allowUnknownTags": true
24+
},
25+
"templates": {
26+
"cleverLinks": false,
27+
"default": {
28+
"includeDate": false,
29+
"outputSourceFiles": true
30+
},
31+
"monospaceLinks": false
32+
}
33+
}

0 commit comments

Comments
 (0)