Skip to content

Commit

Permalink
Adds JavaScript runtime docs, clarity on 11ty/eleventy#3577 and 11ty/…
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Jan 29, 2025
1 parent c05351f commit 9ba7e7f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
]
},
"devDependencies": {
"@11ty/eleventy": "3.0.1-alpha.1",
"@11ty/eleventy": "3.0.1-alpha.3",
"@11ty/eleventy-activity-feed": "^2.0.0",
"@11ty/eleventy-fetch": "^5.0.2",
"@11ty/eleventy-img": "^6.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/_data/npmVersions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function getLatestVersions() {

export default async function () {
try {
return await getLatestVersions();
return getLatestVersions();
} catch (e) {
if (process.env.NODE_ENV === "production") {
// Fail the build in production.
Expand Down
3 changes: 3 additions & 0 deletions src/_includes/components/syntax-highlight.webc
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ syntax-highlight > pre {
</style>
<div webc:if="hed" class="syntax-title"><b @text="hedType || 'Filename'"></b><span @text="hed"></span></div>
<script webc:type="js">
if(!language) {
throw new Error("Missing `language` attribute on <syntax-highlight>.");
}
this.helpers.highlight(language, this.slots.text.default.trim()); // TODO? line highlighting
</script>
4 changes: 2 additions & 2 deletions src/docs/index.webc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ overrideCommunityLinks: true
{% endcallout %}
</template>

<p>Eleventy <eleventy-version></eleventy-version> requires <strong><a href="https://nodejs.org/">Node.js</a> version <node-minimum></node-minimum></strong> or higher.</p>
<p>Eleventy <eleventy-version></eleventy-version> requires a <a href="javascript-runtime.webc">JavaScript runtime</a>, usually <strong><a href="https://nodejs.org/">Node.js</a></strong> — <strong>version <node-minimum></node-minimum></strong> or higher.</p>

<p>You can check whether or not you have Node installed by running <code>node --version</code> in a terminal application. (<a href="/docs/terminal-window/"><em>Well, wait—what is a Terminal?</em></a>) If the command is not found or it reports a number lower than <node-minimum></node-minimum>, you will need to <a href="https://nodejs.org/en/download/">download and install Node.js</a> before moving on to the next step.</p>
<p>You can check whether or not you have Node installed by running <code>node --version</code> in a terminal application. (<a href="/docs/terminal-window/"><em>Well, wait—what is a Terminal?</em></a>) If the command is not found or it reports a number lower than <node-minimum></node-minimum>, you will need to <a href="https://nodejs.org/en/download/">download and install Node.js</a> before moving on to the next step. We encourage folks to use <a href="javascript-runtime.webc#odd-versions-of-node-js">even numbered releases</a> of Node.js.</p>

<p>Prefer to watch videos instead? Check out <a href="https://www.youtube.com/watch?v=kzf9A9tkkl4"><strong>6 minutes to Build a Blog from Scratch</strong></a>.</p>

Expand Down
39 changes: 39 additions & 0 deletions src/docs/javascript-runtime.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---js
// <script>
const eleventyNavigation = {
parent: "Getting Started",
key: "Installing a JavaScript Runtime (like Node.js)",
title: "Installing JavaScript",
order: 0,
};

const excludeFromSidebar = true;
---
<h1>Installing a JavaScript Runtime</h1>

<p>To run Eleventy on your machine, you need at least one JavaScript Runtime (a program to run JavaScript code) installed on your computer. The most common of these is <a href="https://nodejs.org/">Node.js</a>.</p>

<h2>Node.js</h2>

<p>You can check whether or not you have Node installed by running <code>node --version</code> in a terminal application. (<a href="/docs/terminal-window/"><em>Well, wait—what is a Terminal?</em></a>)</p>

<p>If the command is not found or it reports a number lower than <node-minimum></node-minimum>, you will need to head over to <a href="https://nodejs.org/en"><code>nodejs.org</code></a> to download and install <strong>Node.js version <node-minimum></node-minimum></strong> or higher (required by Eleventy <eleventy-version></eleventy-version>).</p>

<p>For more advanced use cases (e.g. having multiple versions of Node.js installed simultaneously) on your computer, it’s common to use a tool called <a href="https://github.com/nvm-sh/nvm"><code>nvm</code></a>. Platform-specific installation instructions for <code>nvm</code> are available at: <a href="https://nodejs.org/en/download"><code>nodejs.org/en/download</code></a>.</p>

<h3>Odd Versions of Node.js</h3>

<p>It is not recommended (or supported by the Eleventy project) to use an odd major version of Node.js (e.g. Node 19), per guidance on the <a href="https://nodejs.org/en/about/previous-releases">Node.js Releases documentation</a>. Our experience has found that major versions are more reliable and we encourage folks to stick with even major version numbers of Node.js whenever possible!</p>

<h2>Deno</h2>

<p>You can use <a href="https://deno.com/">Deno</a> with Eleventy, too. Only the latest major version of Deno is supported by Eleventy. You can check if Deno is installed on your machine by running <code>deno --version</code>.</p>

<p>Rather than using <code>npx</code>, you’ll run Eleventy like this:</p>

<syntax-highlight language="shell">
deno --allow-all npm:@11ty/eleventy
deno --allow-all npm:@11ty/eleventy --serve
</syntax-highlight>

<p>Read about our plans to <a href="https://github.com/11ty/eleventy/issues/3278">move away from <code>--allow-all</code> on #3278</a>.</p>

0 comments on commit 9ba7e7f

Please sign in to comment.