Skip to content

Commit a9cfe21

Browse files
committed
docs: complete rewrite
1 parent 5ca0339 commit a9cfe21

File tree

216 files changed

+31046
-3638
lines changed

Some content is hidden

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

216 files changed

+31046
-3638
lines changed

docs/LICENSE

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
2121
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
2222
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2323
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24-
OTHER DEALINGS IN THE SOFTWARE.
25-
26-
English Česky
24+
OTHER DEALINGS IN THE SOFTWARE.

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Lesy docs
1+
# Lesy JS documentation

docs/builder/doc/create-pages.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const { routes, redirected } = require("../../lesy-routes");
2+
const { iteratePages, sidebarMenuItems } = require("./utils");
3+
4+
exports.createPages = async ({ actions }) => {
5+
const { createRedirect, createPage } = actions;
6+
7+
const pages = iteratePages(routes);
8+
const sidebarItems = sidebarMenuItems(pages);
9+
10+
pages.forEach(page => {
11+
createPage({
12+
component: require.resolve("../../src/templates/doc.template.js"),
13+
path: page.slug,
14+
context: { ...page, sidebarItems: sidebarItems[page.parent.path] },
15+
});
16+
});
17+
18+
redirected.forEach(({ from, to }) => {
19+
createRedirect({
20+
fromPath: from,
21+
toPath: to,
22+
isPermanent: true,
23+
redirectInBrowser: true,
24+
});
25+
});
26+
};

docs/builder/doc/create-schema.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const appConfig = require("../../lesy-config.json");
2+
exports.createSchemaCustomization = ({ actions, schema }) => {
3+
const { createTypes } = actions;
4+
const typeDefs = [
5+
"type Mdx implements Node { frontmatter: Frontmatter }",
6+
schema.buildObjectType({
7+
name: "Frontmatter",
8+
fields: {
9+
icon: {
10+
type: "String",
11+
resolve(source, args, context, info) {
12+
const { icon } = source;
13+
if (source.icon == null) {
14+
return appConfig.doc["default-page-icon"];
15+
}
16+
return icon;
17+
},
18+
},
19+
},
20+
}),
21+
];
22+
createTypes(typeDefs);
23+
};

docs/builder/doc/utils.js

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
const groupBy = require("lodash/groupBy");
2+
3+
const addPageNav = pages => {
4+
return pages.map((page, index) => {
5+
return { ...page, prev: pages[index - 1], next: pages[index + 1] };
6+
});
7+
};
8+
const iteratePages = routes => {
9+
const pages = [];
10+
Object.keys(routes).forEach(parentPath => {
11+
const parent = routes[parentPath];
12+
Object.keys(parent).forEach(sectionPath => {
13+
const section = parent[sectionPath];
14+
section.children.forEach(({ path: childPath, label }) => {
15+
const page = {
16+
slug: [parentPath, sectionPath, childPath].join("/"),
17+
parent: { path: parentPath },
18+
section: { name: section.label, data: section.ctx },
19+
name: label,
20+
};
21+
pages.push(page);
22+
});
23+
});
24+
});
25+
return addPageNav(pages);
26+
};
27+
28+
const getAlgoliaQueries = () => {
29+
const query = `
30+
{
31+
posts: allMdx(
32+
filter: { fileAbsolutePath: { regex: "/content/docs/" } }
33+
) {
34+
edges {
35+
node {
36+
objectID: id
37+
frontmatter {
38+
title
39+
summary
40+
}
41+
excerpt(pruneLength: 5000)
42+
}
43+
}
44+
}
45+
}
46+
`;
47+
const settings = { attributesToSnippet: [`excerpt:20`] };
48+
return [
49+
{
50+
query,
51+
transformer: ({ data }) =>
52+
data.posts.edges.map(({ node: { frontmatter, ...rest } }) => {
53+
return {
54+
...frontmatter,
55+
...rest,
56+
};
57+
}),
58+
indexName: process.env.GATSBY_ALGOLIA_INDEX_NAME,
59+
settings,
60+
},
61+
];
62+
};
63+
64+
const getGithubGraphQL = () => {
65+
return `
66+
query {
67+
repository(name: "lesyjs", owner: "lokesh-coder") {
68+
id
69+
forkCount
70+
issues {
71+
totalCount
72+
}
73+
stargazers {
74+
totalCount
75+
}
76+
collaborators(first: 100) {
77+
edges {
78+
node {
79+
id
80+
url
81+
avatarUrl
82+
}
83+
}
84+
}
85+
updatedAt
86+
releases(first: 100, orderBy: { field: CREATED_AT, direction: DESC }) {
87+
edges {
88+
node {
89+
id
90+
author {
91+
id
92+
}
93+
descriptionHTML
94+
}
95+
}
96+
}
97+
}
98+
}`;
99+
};
100+
101+
const sidebarMenuItems = pages => {
102+
const groups = groupBy(pages, p => p.parent.path);
103+
return groups;
104+
};
105+
106+
module.exports = {
107+
iteratePages,
108+
getAlgoliaQueries,
109+
sidebarMenuItems,
110+
getGithubGraphQL,
111+
};

docs/builders/create-doc-nodes.js

Lines changed: 0 additions & 48 deletions
This file was deleted.

docs/builders/create-doc-page.js

Lines changed: 0 additions & 76 deletions
This file was deleted.

docs/builders/create-doc-pages.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

docs/builders/index.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/config/doc-pages-config.js

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)