Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
userdocs committed Mar 19, 2024
1 parent 10e216c commit 1f66fe3
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ indent_style = space
indent_size = 2

[**.astro]
indent_size = 4
indent_size = 2
indent_style = tab
end_of_line = lf
116 changes: 58 additions & 58 deletions docs/src/pages/glossary.astro
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
---
import StarlightPage from "@astrojs/starlight/components/StarlightPage.astro";
import fs from "fs";
import path from "path";
// Directory containing the files
const dir = "src/content/docs/glossary";
// Read the directory and get an array of filenames
const filenames = fs.readdirSync(dir);
// Map over the filenames and read each file's content and metadata
const files = filenames.map((filename) => {
const filePath = path.join(dir, filename);
const content = fs.readFileSync(filePath, "utf-8");
const title = path.basename(filename, path.extname(filename));
return { title, content };
});
// Sort the files alphabetically by title
files.sort((a, b) => a.title.localeCompare(b.title));
// Group the files by the first letter of their title
const sections = files.reduce((acc: { [key: string]: any[] }, file) => {
const firstLetter = file.title.charAt(0).toUpperCase();
if (!acc[firstLetter]) {
acc[firstLetter] = [];
}
acc[firstLetter].push(file);
return acc;
}, {});
const headings = Object.entries(sections).map((section: [string, any]) => ({
depth: 2,
slug: section[0],
text: section[0],
}));
---

<StarlightPage frontmatter={{ title: "Glossary" }} headings={headings}>
{
Object.entries(sections).map((section: [string, any]) => (
<>
<h2 id={section[0]}>{section[0]}</h2>
<ul>
{section[1].map((file: any) => (
<li>
<a href={"/starlight-glossary/glossary/" + file.title}>
{file.title}
</a>
</li>
))}
</ul>
</>
))
}
</StarlightPage>
---
import StarlightPage from "@astrojs/starlight/components/StarlightPage.astro";
import fs from "fs";
import path from "path";
// Directory containing the files
const dir = "src/content/docs/glossary";
// Read the directory and get an array of filenames
const filenames = fs.readdirSync(dir);
// Map over the filenames and read each file's content and metadata
const files = filenames.map((filename) => {
const filePath = path.join(dir, filename);
const content = fs.readFileSync(filePath, "utf-8");
const title = path.basename(filename, path.extname(filename));
return { title, content };
});
// Sort the files alphabetically by title
files.sort((a, b) => a.title.localeCompare(b.title));
// Group the files by the first letter of their title
const sections = files.reduce((acc: { [key: string]: any[] }, file) => {
const firstLetter = file.title.charAt(0).toUpperCase();
if (!acc[firstLetter]) {
acc[firstLetter] = [];
}
acc[firstLetter].push(file);
return acc;
}, {});
const headings = Object.entries(sections).map((section: [string, any]) => ({
depth: 2,
slug: section[0],
text: section[0],
}));
---

<StarlightPage frontmatter={{ title: "Glossary" }} headings={headings}>
{
Object.entries(sections).map((section: [string, any]) => (
<>
<h2 id={section[0]}>{section[0]}</h2>
<ul>
{section[1].map((file: any) => (
<li>
<a href={"/qbittorrent-nox-static/glossary/" + file.title}>
{file.title}
</a>
</li>
))}
</ul>
</>
))
}
</StarlightPage>

0 comments on commit 1f66fe3

Please sign in to comment.