refactor: move docs into docs/ root folder

This commit is contained in:
xHyroM 2023-06-03 17:34:56 +02:00
parent 134f0ce564
commit 3be55e7c81
No known key found for this signature in database
GPG key ID: BE0423F386C436AA
8 changed files with 38 additions and 8 deletions

View file

@ -48,6 +48,7 @@ export default defineConfig({
resolve: { resolve: {
alias: { alias: {
"~": resolve(__dirname, "./src"), "~": resolve(__dirname, "./src"),
"@docs": resolve(__dirname, "./docs"),
"@pages": resolve(__dirname, "./src/pages"), "@pages": resolve(__dirname, "./src/pages"),
"@assets": resolve(__dirname, "./src/assets"), "@assets": resolve(__dirname, "./src/assets"),
"@scripts": resolve(__dirname, "./src/scripts"), "@scripts": resolve(__dirname, "./src/scripts"),

View file

@ -1,7 +1,6 @@
--- ---
title: Experiments title: Experiments
description: How to fetch experiments from the API description: How to fetch experiments from the API
layout: ../../../layouts/docs/ItemLayout.astro
--- ---
# Experiments # Experiments

View file

@ -1,7 +1,6 @@
--- ---
title: Introduction title: Introduction
description: Introduction to the Discord Experiments API description: Introduction to the Discord Experiments API
layout: ../../../layouts/docs/ItemLayout.astro
--- ---
# Introduction # Introduction

View file

@ -34,7 +34,6 @@ const getLinkClasses = (link: Sidebar) => {
/> />
</button> </button>
</div> </div>
<!--<nav aria-labelledby="grid-left" class="w-64 border-r p-4">-->
<nav <nav
id="sidebar" id="sidebar"
aria-labelledby="grid-left" aria-labelledby="grid-left"

View file

@ -1,13 +1,15 @@
--- ---
import TableOfContents from "./TableOfContents.astro"; import TableOfContents from "./TableOfContents.astro";
const { item } = Astro.props; const { item } = Astro.props;
const headings = item.getHeadings();
--- ---
{ {
item.headings.length > 1 && ( headings.length > 1 && (
<nav aria-labelledby="grid-right" class="invisible md:visible"> <nav aria-labelledby="grid-right" class="invisible md:visible">
<div class="px-8"> <div class="px-8">
<TableOfContents headings={item.headings} /> <TableOfContents headings={headings} />
</div> </div>
</nav> </nav>
) )

View file

@ -4,13 +4,13 @@ import RightSidebar from "@components/widgets/docs/RightSidebar.astro";
import Navbar from "@components/widgets/Navbar.astro"; import Navbar from "@components/widgets/Navbar.astro";
import Layout from "@layouts/Layout.astro"; import Layout from "@layouts/Layout.astro";
const item = Astro.props; const { item } = Astro.props;
const currentPage = new URL(Astro.request.url).pathname; const currentPage = new URL(Astro.request.url).pathname;
--- ---
<Layout <Layout
title={`Docs - ${item.content.title}`} title={`Docs - ${item.frontmatter.title}`}
description={item.content.description} description={item.frontmatter.description}
url={`https://xhyrom.dev${item.url}`} url={`https://xhyrom.dev${item.url}`}
> >
<Navbar /> <Navbar />

View file

@ -0,0 +1,29 @@
---
import ItemLayout from "@layouts/docs/ItemLayout.astro";
export async function getStaticPaths() {
const docs = await Astro.glob("@docs/**/*.md");
return docs.map((doc) => {
const path = doc.file.split("/docs/")[1];
const [categoryId, docId] = path.split("/");
return {
params: {
category: categoryId,
id: docId.replace(".md", ""),
},
props: {
...doc,
url: `/docs/${categoryId}/${docId.replace(".md", "")}`,
},
};
});
}
const item = Astro.props;
---
<ItemLayout item={item}>
<div set:html={item.compiledContent()} />
</ItemLayout>

View file

@ -4,6 +4,7 @@
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"~/*": ["src/*"], "~/*": ["src/*"],
"@docs/*": ["docs/*"],
"@pages/*": ["src/pages/*"], "@pages/*": ["src/pages/*"],
"@assets/*": ["src/assets"], "@assets/*": ["src/assets"],
"@scripts/*": ["src/scripts"], "@scripts/*": ["src/scripts"],