Skip to content

Commit a6e6303

Browse files
Merge pull request #67 from CloudCannon/routing-and-initial-site-settings-file
Add routing and initial-site-settings schemas with separate docs
2 parents eba1df1 + 138f5e8 commit a6e6303

685 files changed

Lines changed: 1868 additions & 782 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs-site/eleventy.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import syntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
21
import { RenderPlugin } from '@11ty/eleventy';
2+
import syntaxHighlight from '@11ty/eleventy-plugin-syntaxhighlight';
33
import documentation from '../dist/documentation.json' with { type: 'json' };
44

55
export default function (eleventyConfig) {
66
eleventyConfig.addPlugin(syntaxHighlight);
77
eleventyConfig.addPlugin(RenderPlugin);
8-
eleventyConfig.addGlobalData('docs', Object.values(documentation));
8+
eleventyConfig.addGlobalData('docs', Object.values(documentation['type.Configuration']));
99

1010
eleventyConfig.addFilter('json', (json) => {
1111
if (typeof json === 'object') {

docs/docs.ts

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,28 @@ import path from 'node:path';
33
import { dump, load } from 'js-yaml';
44
import { type DocumentationEntry, type Page, verbose } from './util';
55

6-
export async function readDocs(): Promise<Record<string, DocumentationEntry>> {
6+
export async function readDocs(folder: string): Promise<Record<string, DocumentationEntry>> {
77
const docs: Record<string, DocumentationEntry> = {};
8-
const files = await fs.readdir(path.join(process.cwd(), 'docs/documentation'));
8+
const folderPath = path.join(process.cwd(), folder);
99

10-
console.log(`📄 Read from docs/documentation/*.yml (${files.length})`);
10+
try {
11+
await fs.access(folderPath);
12+
} catch {
13+
console.log(`📄 Read from ${folder}/*.yml (0 - folder does not exist)`);
14+
return docs;
15+
}
16+
17+
const files = await fs.readdir(folderPath);
18+
19+
console.log(`📄 Read from ${folder}/*.yml (${files.length})`);
1120

1221
for (let i = 0; i < files.length; i++) {
1322
if (files[i].endsWith('.yml')) {
1423
if (verbose) {
1524
console.log(` ${files[i]}`);
1625
}
1726

18-
const content = await fs.readFile(path.join(process.cwd(), 'docs/documentation', files[i]), {
27+
const content = await fs.readFile(path.join(folderPath, files[i]), {
1928
encoding: 'utf8',
2029
});
2130

@@ -33,40 +42,61 @@ export async function readDocs(): Promise<Record<string, DocumentationEntry>> {
3342
return docs;
3443
}
3544

36-
export async function moveOldDocs(gidsInUse: Set<string>): Promise<void> {
37-
const allFiles = await fs.readdir(path.join(process.cwd(), 'docs/documentation'));
45+
export async function moveOldDocs(folder: string, gidsInUse: Set<string>): Promise<void> {
46+
const folderPath = path.join(process.cwd(), folder);
47+
const unusedFolder = `${folder}-unused`;
48+
const unusedPath = path.join(process.cwd(), unusedFolder);
49+
50+
try {
51+
await fs.access(folderPath);
52+
} catch {
53+
return;
54+
}
55+
56+
const allFiles = await fs.readdir(folderPath);
3857
const files = allFiles.filter(
3958
(file) => file.endsWith('.yml') && !gidsInUse.has(file.replace(/\.yml$/, ''))
4059
);
4160

42-
await fs.mkdir(path.join(process.cwd(), 'docs/documentation-unused'), { recursive: true });
61+
if (files.length === 0) {
62+
return;
63+
}
64+
65+
await fs.mkdir(unusedPath, { recursive: true });
4366

44-
console.log(`🚚 Move to docs/documentation-unused/*.yml (${files.length})`);
67+
console.log(`🚚 Move to ${unusedFolder}/*.yml (${files.length})`);
4568

4669
for (let i = 0; i < files.length; i++) {
4770
if (verbose) {
4871
console.log(` ${files[i]}`);
4972
}
5073

51-
await fs.rename(
52-
path.join(process.cwd(), 'docs/documentation', files[i]),
53-
path.join(process.cwd(), 'docs/documentation-unused', files[i])
54-
);
74+
await fs.rename(path.join(folderPath, files[i]), path.join(unusedPath, files[i]));
5575
}
5676
}
5777

58-
export async function writeNewDocs(gids: Set<string>, pages: Record<string, Page>): Promise<void> {
78+
export async function writeNewDocs(
79+
folder: string,
80+
gids: Set<string>,
81+
pages: Record<string, Page>
82+
): Promise<void> {
83+
const folderPath = path.join(process.cwd(), folder);
5984
const pageFiles: any[] = [];
6085

61-
const files = await fs.readdir(path.join(process.cwd(), 'docs/documentation'));
62-
const existingGids = files.reduce((memo: Record<string, boolean>, file) => {
63-
memo[file.replace(/\.yml$/, '')] = true;
64-
return memo;
65-
}, {});
86+
await fs.mkdir(folderPath, { recursive: true });
87+
88+
let existingGids: Record<string, boolean> = {};
89+
try {
90+
const files = await fs.readdir(folderPath);
91+
existingGids = files.reduce((memo: Record<string, boolean>, file) => {
92+
memo[file.replace(/\.yml$/, '')] = true;
93+
return memo;
94+
}, {});
95+
} catch {}
6696

6797
let newCount = 0;
6898

69-
console.log(`📝 Write to docs/documentation/*.yml (${gids.size})`);
99+
console.log(`📝 Write to ${folder}/*.yml (${gids.size})`);
70100

71101
gids.forEach((gid) => {
72102
if (!existingGids[gid]) {
@@ -85,8 +115,6 @@ export async function writeNewDocs(gids: Set<string>, pages: Record<string, Page
85115
});
86116
});
87117

88-
await fs.mkdir(path.join(process.cwd(), 'docs/documentation'), { recursive: true });
89-
90118
for (let i = 0; i < pageFiles.length; i++) {
91119
const pageFile = pageFiles[i];
92120
const filename = `${pageFile.gid}.yml`;
@@ -95,10 +123,7 @@ export async function writeNewDocs(gids: Set<string>, pages: Record<string, Page
95123
console.log(` ${filename}`);
96124
}
97125

98-
await fs.writeFile(
99-
path.join(process.cwd(), 'docs/documentation', filename),
100-
dump(pageFile, { noRefs: true })
101-
);
126+
await fs.writeFile(path.join(folderPath, filename), dump(pageFile, { noRefs: true }));
102127
}
103128

104129
console.log(` 🆕 New (${newCount})`);

docs/documentation/_snippets_definitions_from_glob.[*].yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
gid: _snippets_definitions_from_glob.[*]
2-
url: /_snippets_definitions_from_glob/[*]/
2+
url: /configuration-file/_snippets_definitions_from_glob/[*]/
33
title: ''
44
description: ''
55
examples: []

docs/documentation/_snippets_definitions_from_glob.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
gid: _snippets_definitions_from_glob
2-
url: /_snippets_definitions_from_glob/
2+
url: /configuration-file/_snippets_definitions_from_glob/
33
title: ''
44
description: ''
55
examples: []

docs/documentation/_snippets_from_glob.[*].yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
gid: _snippets_from_glob.[*]
2-
url: /_snippets_from_glob/[*]/
2+
url: /configuration-file/_snippets_from_glob/[*]/
33
title: ''
44
description: >-
55
This key represents an individual glob pattern string in the

docs/documentation/_snippets_from_glob.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
gid: _snippets_from_glob
2-
url: /_snippets_from_glob/
2+
url: /configuration-file/_snippets_from_glob/
33
title: ''
44
description: >-
55
This key defines globs that filter which files CloudCannon should use for

docs/documentation/_snippets_imports_from_glob.[*].yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
gid: _snippets_imports_from_glob.[*]
2-
url: /_snippets_imports_from_glob/[*]/
2+
url: /configuration-file/_snippets_imports_from_glob/[*]/
33
title: ''
44
description: >-
55
This key represents an individual glob pattern string in the

docs/documentation/_snippets_imports_from_glob.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
gid: _snippets_imports_from_glob
2-
url: /_snippets_imports_from_glob/
2+
url: /configuration-file/_snippets_imports_from_glob/
33
title: ''
44
description: >-
55
This key defines globs that filter which files CloudCannon should use for

docs/documentation/_snippets_templates_from_glob.[*].yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
gid: _snippets_templates_from_glob.[*]
2-
url: /_snippets_templates_from_glob/[*]/
2+
url: /configuration-file/_snippets_templates_from_glob/[*]/
33
title: ''
44
description: ''
55
examples: []

docs/documentation/_snippets_templates_from_glob.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
gid: _snippets_templates_from_glob
2-
url: /_snippets_templates_from_glob/
2+
url: /configuration-file/_snippets_templates_from_glob/
33
title: ''
44
description: ''
55
examples: []

0 commit comments

Comments
 (0)