Add website sitemap
MODIFY
scripts/_utils.cjs
scripts/_utils.cjs
@@ -158,10 +158,10 @@ exports.buildTrunk = async function() {
]);
};
-const COMMENT_REGEX = /\/\/ EVERYTHING BELOW IS AUTOGENERATED\. SEE SCRIPTS FOLDER FOR UPDATE SCRIPTS([\s\S]+)$/;
-const COMMENT_TEXT = "// EVERYTHING BELOW IS AUTOGENERATED. SEE SCRIPTS FOLDER FOR UPDATE SCRIPTS";
+const COMMENT_REGEX = /(\/\/|<!--) EVERYTHING BELOW IS AUTOGENERATED\. SEE SCRIPTS FOLDER FOR UPDATE SCRIPTS([\s\S]+)$/;
+const COMMENT_TEXT = "EVERYTHING BELOW IS AUTOGENERATED. SEE SCRIPTS FOLDER FOR UPDATE SCRIPTS";
-exports.readGeneratedFile = function(loc, raw) {
+exports.readGeneratedFile = function(loc, raw, type) {
let file = exports.readFile(loc, "utf8");
if (raw) {
return file;
@@ -170,7 +170,15 @@ exports.readGeneratedFile = function(loc, raw) {
file = file.replace(COMMENT_REGEX, "");
file = file.trim();
file += "\n\n";
+ if (type === "html") {
+ file += "<!-- ";
+ } else {
+ file += "// ";
+ }
file += COMMENT_TEXT;
+ if (type === "html") {
+ file += " -->";
+ }
file += "\n\n";
return file;
};

MODIFY
scripts/assert-generated
scripts/assert-generated
@@ -16,6 +16,7 @@ const {execDev, writtenFiles} = require("./_utils.cjs");
require("./runtime-modules/update.cjs");
require("./ast/update.cjs");
require("./lint/update.cjs");
+require("./sitemap/update.cjs");
//only .ts will be autofixed
const filteredWrittenFiles = writtenFiles.filter(function(file){

MODIFY
scripts/lint/update.cjs
scripts/lint/update.cjs
@@ -79,10 +79,7 @@ function getDocRuleDescription(content) {
const lintRulesDocFile = path.join(lintRulesDocFolder, "index.md");
-let docTemplate = readGeneratedFile(lintRulesDocFile);
-
-//close tag to hide the comment about file being autogenerated
-docTemplate += "</span>\n\n";
+let docTemplate = readGeneratedFile(lintRulesDocFile, false, "html");
//Used for doc headings
const categoryAlias = {

ADD
scripts/sitemap/update.cjs
+require("../_setup.cjs");
+
+const {readGeneratedFile, write, readFile} = require("../_utils.cjs");
+const {root} = require("../_constants.cjs");
+const path = require("path");
+const fs = require("fs");
+
+const src = path.join(root, "website", "src");
+const sitemapFile = path.join(src, "sitemap.md");
+let sitemapTemplate = readGeneratedFile(sitemapFile, false, "html");
+
+const tree = buildTree(src);
+
+function buildTree(folder) {
+ let children = [];
+
+ const files = fs.readdirSync(folder).sort();
+ for (const name of files) {
+ if (name[0] === "_") {
+ continue;
+ }
+
+ const loc = path.join(folder, name);
+ const url = `/${path.relative(src, loc)}`;
+
+ const stats = fs.statSync(loc);
+ if (stats.isFile() && name.endsWith(".md")) {
+ const file = readFile(loc);
+ const headingMatch = file.match(/# (.*?)\n/);
+ const heading = headingMatch == null ? undefined : headingMatch[1];
+
+ children.push({
+ type: "file",
+ heading,
+ link: true,
+ children: [],
+ // Remove .md
+ url: url.slice(0, -3),
+ name: name.slice(0, -3),
+ });
+ } else if (stats.isDirectory()) {
+ const node = buildTree(loc);
+ if (node.children.length > 0 || node.link) {
+ children.push(node);
+ }
+ }
+ }
+
+ let index;
+ children = children.filter((child) => {
+ if (child.name === "index") {
+ index = child;
+ return false;
+ } else {
+ return true;
+ }
+ });
+
+ return {
+ type: "folder",
+ url: `/${path.relative(src, folder)}`,
+ link: index !== undefined,
+ heading: index && index.heading,
+ name: folder === src ? "" : path.basename(folder),
+ children,
+ };
+}
+
+function pushList(node, level) {
+ let text = `\`/${node.name}\``;
+
+ if (node.link) {
+ text = `[${text}](${node.url})`;
+ }
+
+ if (node.heading) {
+ text += `: ${node.heading}`;
+ }
+
+ sitemapTemplate += `${" ".repeat(level)} - ${text}\n`;
+
+ if (node.type === "folder") {
+ for (const child of node.children) {
+ pushList(child, level + 1);
+ }
+ }
+}
+
+pushList(tree, 0);
+
+write(sitemapFile, sitemapTemplate);

MODIFY
website/src/docs/lint/rules/index.md
website/src/docs/lint/rules/index.md
@@ -8,9 +8,7 @@ showHero: false
<span style="display: none;">
-// EVERYTHING BELOW IS AUTOGENERATED. SEE SCRIPTS FOLDER FOR UPDATE SCRIPTS
-
-</span>
+<!-- EVERYTHING BELOW IS AUTOGENERATED. SEE SCRIPTS FOLDER FOR UPDATE SCRIPTS -->
## Javascript

MODIFY
website/src/docs/lint/rules/js/camel-case.md
website/src/docs/lint/rules/js/camel-case.md
@@ -5,6 +5,6 @@ showHero: false
description: This rule enforce the use of camelCase
---
-# camel-case
+# camelCase
not documented yet

DELETE
website/src/docs/sitemap.md
----
-title: Sitemap
-layout: layouts/page.njk
----

MODIFY
website/src/index.md
website/src/index.md
layout: layouts/homepage.njk
---
+<!--
+# The Rome Frontend Toolchain
+-->
+
**Rome** is a linter, compiler, bundler, and [more](https://romefrontend.dev/#development-status) for JavaScript, TypeScript, HTML, Markdown, and CSS. Read more about our language support [here](https://romefrontend.dev/docs/language-support).
**Rome** unifies functionality that has previously been completely separate tools. Most frontend tooling have a significant overlap in responsibilities and implementation. There is value in these being a single tool. Building upon a shared base allows us to provide a cohesive experience for processing code, displaying errors, parallelizing work, caching, and configuration.

ADD
website/src/sitemap.md
+---
+title: Sitemap
+layout: layouts/page.njk
+---
+
+# Sitemap
+
+<!-- EVERYTHING BELOW IS AUTOGENERATED. SEE SCRIPTS FOLDER FOR UPDATE SCRIPTS -->
+
+ - [`/`](/): The Rome Frontend Toolchain
+ - `/blog`
+ - `/posts`
+ - [`/test-test`](/blog/posts/test-test)
+ - [`/test`](/blog/posts/test): Section Header
+ - [`/contributing`](/contributing)
+ - [`/governance`](/contributing/governance)
+ - [`/philosophy`](/contributing/philosophy): Philosophy
+ - [`/team`](/contributing/team): Team
+ - `/docs`
+ - [`/cli`](/docs/cli): CLI
+ - `/commands`
+ - [`/check`](/docs/cli/commands/check): `rome check`
+ - [`/config`](/docs/cli/commands/config): `rome config`
+ - [`/init`](/docs/cli/commands/init): `rome init`
+ - [`/logs`](/docs/cli/commands/logs): `rome logs`
+ - [`/lsp`](/docs/cli/commands/lsp): `rome lsp`
+ - [`/noop`](/docs/cli/commands/noop): `rome noop`
+ - [`/rage`](/docs/cli/commands/rage): `rome rage`
+ - [`/start`](/docs/cli/commands/start): `rome start`
+ - [`/status`](/docs/cli/commands/status): `rome status`
+ - [`/stop`](/docs/cli/commands/stop): `rome stop`
+ - [`/debugging`](/docs/cli/debugging): Debugging
+ - [`/server`](/docs/cli/server): Server
+ - [`/diagnostics`](/docs/diagnostics): Diagnostics
+ - [`/editor-integration`](/docs/editor-integration): Editor Integration
+ - [`/getting-started`](/docs/getting-started): Getting Started
+ - [`/language-support`](/docs/language-support): Language Support
+ - [`/lint`](/docs/lint): Linting
+ - [`/rules`](/docs/lint/rules): Rules
+ - `/js`
+ - [`/camel-case`](/docs/lint/rules/js/camel-case): camelCase
+ - [`/no-nested-ternary`](/docs/lint/rules/js/no-nested-ternary): noNestedTernary
+ - [`/no-unused-template-literal`](/docs/lint/rules/js/no-unused-template-literal): noUnusedTemplateLiteral
+ - `/jsx`
+ - [`/no-implicit-boolean`](/docs/lint/rules/jsx/no-implicit-boolean): noImplicitBoolean
+ - [`/project-config`](/docs/project-config): Project Configuration
+ - [`/rjson`](/docs/rjson): Comments
+ - [`/sitemap`](/sitemap): Sitemap

Add website sitemap (#788)