Skip to content

Commit

Permalink
clean up docs
Browse files Browse the repository at this point in the history
  • Loading branch information
reednel committed Jan 10, 2024
1 parent fd2ee65 commit c6e980a
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 121 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2023 Jane Doe
Copyright (c) 2024 Jane Doe

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
11 changes: 0 additions & 11 deletions src/config/config.ts

This file was deleted.

38 changes: 29 additions & 9 deletions src/config/docs.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
{
"Get Started": [
"/docs/get-started/introduction/",
"/docs/get-started/installation/"
],
"Tutorials": [
"/docs/tutorials/build-x/"
],
"Guides": [
"/docs/guides/migrate-from-z/"
"main": [
{
"text": "Get Started",
"header": true
},
{
"text": "Installation",
"link": "/docs/get-started/installation"
},
{
"text": "Introduction",
"link": "/docs/get-started/introduction"
},
{
"text": "Guides",
"header": true
},
{
"text": "Migrate from Z",
"link": "/docs/guides/migrate-from-z"
},
{
"text": "Tutorials",
"header": true
},
{
"text": "Build X",
"link": "/docs/tutorials/build-x"
}
]
}
6 changes: 3 additions & 3 deletions src/content/terms/-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ draft: false

## Copyright

© 2023 Jane Doe. All rights reserved.
© 2024 Jane Doe. All rights reserved.

## Reuse

Expand All @@ -17,7 +17,7 @@ The source code for janedoe.com is protected under the MIT License. In short, yo
```md
The MIT License (MIT)

Copyright (c) 2023 Jane Doe
Copyright (c) 2024 Jane Doe

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -54,7 +54,7 @@ This source code is derivative of [pages](https://github.com/reednel/pages) by [
```md
The MIT License (MIT)

Copyright (c) 2023 Reed Nelson
Copyright (c) 2024 Reed Nelson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
25 changes: 6 additions & 19 deletions src/layouts/DocsSingle.astro → src/layouts/DocSingle.astro
Original file line number Diff line number Diff line change
@@ -1,44 +1,31 @@
---
import DocBrowser from '@/components/DocBrowser.astro';
import DocContents from '@/components/DocContents.astro';
import Share from "@/components/Share.astro";
import config from "@/config/config.json";
const { post } = Astro.props;
const { Content, headings } = await post.render();
const { title } = post.data;
const currentPage = new URL(Astro.request.url).pathname;
const { docs_folder } = config.settings;
---

<section class="section pt-7">
<div class="container">
<div class="row justify-center">
<div class="grid grid-cols-12">
<!-- Document Browser (Left) -->
<div class="col-span-3 sticky top-0 pt-12 h-screen flex">
<div class="col-span-3 sticky top-0 h-screen flex">
<div class="ml-auto">
<DocBrowser currentPage={currentPage} />
</div>
</div>
<!-- Content -->
<main class="py-4 px-8 pb-32 col-span-6 overflow-auto">
<div>
<Content />
<!-- Share -->
<div class="row items-start justify-between">
<div class="flex items-center mt-8">
<h5 class="mr-3">Share :</h5>
<Share
className="social-icons"
title={title}
description={"description"}
folder={docs_folder}
slug={post.slug}
/>
</div>
<article>
<h1 class="mb-4">{ title }</h1>
<div class="content mb-10">
<Content />
</div>
</div>
</article>
</main>
<!-- Document Contents (Right) -->
<div class="col-span-3 sticky top-0 h-screen flex">
Expand Down
74 changes: 44 additions & 30 deletions src/layouts/components/DocBrowser.astro
Original file line number Diff line number Diff line change
@@ -1,44 +1,58 @@
---
import { SIDEBAR } from '@/config/config.ts';
import docs from "@/config/docs.json";
const { currentPage } = Astro.props;
const currentPageMatch = currentPage.slice(1);
const isCurrentPage = (item) => {
if (item.link) {
return item.link.includes(currentPageMatch);
}
return false;
if (item.link) {
return item.link.includes(currentPageMatch);
}
return false;
};
const getLinkClasses = (link) => {
const baseClasses = "block py-2 px-6 my-1 transition-colors border-l hover:border-slate-400 text-slate-500 hover:text-slate-900"
const baseClasses =
"block py-2 px-6 my-1 transition-colors border-l hover:border-slate-400 text-slate-500 hover:text-slate-900";
if (isCurrentPage(link)) {
return baseClasses + " border-slate-500 text-slate-900";
} else {
return baseClasses;
}
if (isCurrentPage(link)) {
return baseClasses + " border-slate-500 text-slate-900";
} else {
return baseClasses;
}
};
export interface doc_data {
text: string;
header?: boolean;
link?: string;
}
const { main }: { main: doc_data[] } = docs;
---
<aside title="Site Navigation">
<!-- <Debug content={navigation} /> -->
<nav aria-labelledby="grid-left" class="w-64 p-4 border-r">
<ul>
{SIDEBAR.map(item => (item.header ?
<h2 class="mt-4 font-semibold text-slate-700">{item.text}</h2> :
<li class={getLinkClasses(item)}>
<a href={item.link}>{item.text}</a>
</li>))}
</ul>
</nav>
</aside>

<nav aria-labelledby="grid-left" class="w-64 border-r">
<div class="px-4 py-16">
<ul>
{
main.map((item) =>
item.header ? (
<h3 class="font-semibold text-slate-700">{item.text}</h3>
) : (
<li class={getLinkClasses(item)}>
<a href={item.link}>{item.text}</a>
</li>
),
)
}
</ul>
</div>
</nav>

<script is:inline>
window.addEventListener('DOMContentLoaded', (event) => {
var target = document.querySelector('[aria-current="page"]');
if (target && target.offsetTop > window.innerHeight - 100) {
document.querySelector('.nav-groups').scrollTop = target.offsetTop;
}
});
window.addEventListener("DOMContentLoaded", (event) => {
var target = document.querySelector('[aria-current="page"]');
if (target && target.offsetTop > window.innerHeight - 100) {
document.querySelector(".nav-groups").scrollTop = target.offsetTop;
}
});
</script>

71 changes: 28 additions & 43 deletions src/layouts/components/DocContents.astro
Original file line number Diff line number Diff line change
@@ -1,48 +1,33 @@
---
const { headings } = Astro.props;
const { headings } = Astro.props;
---
<!-- <ul class="flex flex-col gap-4 mt-24">
{ headings.map(({ slug, text }) => {
return (
<li class="text-slate-400 hover:text-slate-800">
#<a href={`#${slug}`}>{text}</a>
</li>
)
}) }
</ul> -->

<nav aria-labelledby="grid-right">
<div class="px-8">
<div id="_anchor" class="fixed top-0 py-24 px-4">
<h1 class="dark:text-white text-xl my-4">On This Page</h1>
{headings.map((heading) => {
let Heading: any = `h${heading.depth}`;
let className = `peer border-l-2 border-l-zinc-400 dark:border-l-zinc-700 `
switch (heading.depth) {
case 2:
className += `pl-2`;
break;
case 3:
className += `pl-4`;
break;
case 4:
className += `pl-6`;
break;
case 5:
className += `pl-8`;
break;
case 6:
className += `pl-10`;
break;
default:
break;
}
return <Heading class={className}>
<a href={`#${heading.slug}`} class="block py-1 text-zinc-600 dark:text-zinc-400 hover:text-green-600 dark:hover:text-zinc-300 transition-colors">
{heading.text}
</a>
</Heading>
})}
</div>
</div>
<div class="px-4 py-16">
<h3 class="dark:text-white mb-4">On This Page</h3>
{
headings.map((heading) => {
let className = `peer border-l-2 border-l-zinc-400 dark:border-l-zinc-700 `;
const sizeAndIndent = {
1: `pl-0 text-3xl`,
2: `pl-2 text-2xl`,
3: `pl-4 text-xl`,
4: `pl-6 text-lg`,
5: `pl-8 text-base`,
6: `pl-10 text-sm`,
};
className += sizeAndIndent[heading.depth] || "";
return (
<p class={className}>
<a
href={`#${heading.slug}`}
class="block py-1 text-zinc-600 dark:text-zinc-400 hover:text-green-600 dark:hover:text-zinc-300 transition-colors"
>
{heading.text}
</a>
</p>
);
})
}
</div>
</nav>
2 changes: 1 addition & 1 deletion src/layouts/components/Footer.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import social from "@/config/social.json";
<div class="mb-2 text-center lg:col-6 lg:mb-0 lg:text-left">
<ul>
<li class="m-3 inline-block">
<a href="/terms">&copy; Jane Doe 2023</a>
<a href="/terms">&copy; Jane Doe 2024</a>
</li>
</ul>
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/pages/docs/[...id].astro
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
import Base from "@/layouts/Base.astro";
import DocsSingle from "@/layouts/DocsSingle.astro";
import DocSingle from "@/layouts/DocSingle.astro";
import { getSinglePage } from "@/lib/contentParser.astro";
import { getCollection } from 'astro:content';
import config from "@/config/config.json";
export async function getStaticPaths() {
const docs = await getCollection('docs');
const docs = await getSinglePage(config.settings.docs_folder);
return docs.map(post => ({
params: { id: post.slug },
props: { post },
Expand All @@ -20,5 +20,5 @@ const { title } = post.data;
title={title}
meta_title={title}
>
<DocsSingle post={post} />
<DocSingle post={post} />
</Base>

0 comments on commit c6e980a

Please sign in to comment.