Skip to content

Commit 61ea78a

Browse files
authored
Docs: Added a getting started section (#799)
1 parent b8f6460 commit 61ea78a

File tree

7 files changed

+120
-46
lines changed

7 files changed

+120
-46
lines changed

src/data/docsTree.ts

Lines changed: 66 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,84 @@ import type { DocsMetadata, DocsNode, DocsTree } from "$data/docs";
22
import { error } from "@sveltejs/kit";
33

44
const PATH_TRIM = /(?:\.\.\/routes\/docs)((\/[\w-]+)+)\//;
5+
const PRIORITY_CATEGORY = "Getting Started";
6+
const PRIORITY_PAGES = ["Overview", "Install"];
57

68
const getPages = () => {
7-
const rawPages = import.meta.glob<DocsMetadata>(
8-
["../routes/docs/**/*/+page.md", "../routes/docs/+page.md"], // import all docs pages + base page
9-
{ eager: true, import: "metadata" },
10-
);
9+
const rawPages = import.meta.glob<DocsMetadata>(
10+
["../routes/docs/**/*/+page.md", "../routes/docs/+page.md"],
11+
{ eager: true, import: "metadata" },
12+
);
1113

12-
return Object.entries(rawPages).map(([path, node]) => {
13-
return {
14-
title: node.title,
15-
path: path.match(PATH_TRIM)?.[1] ?? "",
16-
} as DocsNode;
17-
});
14+
return Object.entries(rawPages).map(([path, node]) => {
15+
return {
16+
title: node.title,
17+
path: path.match(PATH_TRIM)?.[1] ?? "",
18+
} as DocsNode;
19+
});
1820
};
1921

2022
const getTree = (pages: DocsNode[]) => {
21-
const rawCategories = import.meta.glob<DocsMetadata>(
22-
"../routes/docs/**/*/category.md",
23-
{
24-
eager: true,
25-
import: "metadata",
26-
},
27-
);
23+
const rawCategories = import.meta.glob<DocsMetadata>(
24+
"../routes/docs/**/*/category.md",
25+
{
26+
eager: true,
27+
import: "metadata",
28+
},
29+
);
2830

29-
const categories: DocsTree = Object.entries(rawCategories).map(
30-
([path, node]) => {
31-
const docsPath = path.match(PATH_TRIM)?.[1];
32-
if (!docsPath) error(500, `this is an invalid docs page path: ${path}`);
31+
const categories: DocsTree = Object.entries(rawCategories).map(
32+
([path, node]) => {
33+
const docsPath = path.match(PATH_TRIM)?.[1];
34+
if (!docsPath) error(500, `this is an invalid docs page path: ${path}`);
3335

34-
return {
35-
pages: pages.filter(page => page.path.startsWith(docsPath)),
36-
path: docsPath,
37-
...node,
38-
};
39-
},
40-
);
36+
const categoryPages = pages
37+
.filter(page => page.path.startsWith(docsPath))
38+
.sort((a, b) => {
39+
const aIndex = PRIORITY_PAGES.indexOf(a.title);
40+
const bIndex = PRIORITY_PAGES.indexOf(b.title);
4141

42-
const topLevelPages = import.meta.glob<DocsMetadata>(
43-
["../routes/docs/*/+page.md", "../routes/docs/+page.md"],
44-
{
45-
eager: true,
46-
import: "metadata",
47-
},
48-
);
42+
if (aIndex !== -1 && bIndex !== -1) return aIndex - bIndex;
43+
if (aIndex !== -1) return -1;
44+
if (bIndex !== -1) return 1;
4945

50-
const topLevelData: DocsNode[] = Object.entries(topLevelPages).map(
51-
([path, data]) => {
52-
const docsPath = path.match(PATH_TRIM)?.[1] ?? "";
46+
return a.title.localeCompare(b.title);
47+
});
5348

54-
return {
55-
path: docsPath,
56-
...data,
57-
};
58-
},
59-
);
49+
return {
50+
pages: categoryPages,
51+
path: docsPath,
52+
...node,
53+
};
54+
},
55+
);
6056

61-
return [...topLevelData, ...categories];
57+
const topLevelPages = import.meta.glob<DocsMetadata>(
58+
["../routes/docs/*/+page.md", "../routes/docs/+page.md"],
59+
{
60+
eager: true,
61+
import: "metadata",
62+
},
63+
);
64+
65+
const topLevelData: DocsNode[] = Object.entries(topLevelPages).map(
66+
([path, data]) => {
67+
const docsPath = path.match(PATH_TRIM)?.[1] ?? "";
68+
69+
return {
70+
path: docsPath,
71+
...data,
72+
};
73+
},
74+
);
75+
76+
// Combine and apply category-level sort
77+
return [...topLevelData, ...categories].sort((a, b) => {
78+
if (a.title === PRIORITY_CATEGORY) return -1;
79+
if (b.title === PRIORITY_CATEGORY) return 1;
80+
return a.title.localeCompare(b.title);
81+
});
6282
};
6383

6484
export const docsPages = getPages();
65-
export const docsTree = getTree(docsPages);
85+
export const docsTree = getTree(docsPages);

src/routes/docs/+page.server.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { redirect } from "@sveltejs/kit";
2+
3+
export const load = ({ params }) => {
4+
redirect(301, `/docs/getting-started/overview/${params.rest ?? ""}`);
5+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
title: Getting Started
3+
---
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: Frequently Asked Questions
3+
---
4+
5+
## How to Locate the Log File
6+
7+
If Files launches successfully, the easiest way to access its log file is directly from **Settings → About → Open log location.**. If you're unable to open the UI, you can locate the log manually using File Explorer. The path varies depending on which version of Files is installed:
8+
9+
### Files Stable (Microsoft Store)
10+
11+
```text
12+
%LocalAppData%\\Packages\\49306atecsolution.FilesUWP_et10x9a9vyk8t\\LocalState
13+
```
14+
15+
### Files Stable (Sideload)
16+
17+
```text
18+
%LocalAppData%\\Packages\\Files_1y0xx7n9077q4\\LocalState
19+
```
20+
21+
### Files Preview (Microsoft Store)
22+
23+
```text
24+
%LocalAppData%\\Packages\\49306atecsolution.FilesPreview_et10x9a9vyk8t\\LocalState
25+
```
26+
27+
### Files Preview (Sideload)
28+
29+
```text
30+
%LocalAppData%\\Packages\\FilesPreview_1y0xx7n9077q4\\LocalState
31+
```
32+
33+
## How to Improve Performance
34+
35+
The default settings are designed to deliver the best performance across different environments. We've identified several areas with potential for further optimization and are actively working on improvements behind the scenes.
36+
37+
## How to Reduce Memory Usage
38+
39+
Resource consumption naturally increases when opening new tabs or navigating to different locations. However, we're aware of several memory leaks that can cause usage to accumulate over extended sessions.
40+
41+
To mitigate this, consider disabling the option to keep Files in the background from **Settings → Advanced → Leave app running in the background when the window is closed**. Note that turning this off may result in slower launch times for Files. We're investigating these leaks and looking for a long-term solution.
File renamed without changes.
File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { redirect } from "@sveltejs/kit";
2+
3+
export const load = ({ params }) => {
4+
redirect(301, `/docs/getting-started/install/${params.rest ?? ""}`);
5+
};

0 commit comments

Comments
 (0)