Skip to content

Commit d5ff744

Browse files
authored
Merge pull request #480 from DeterminateSystems/fix-presentation-issues
Fix site presentation issues
2 parents 61ce6ed + 844f45a commit d5ff744

File tree

11 files changed

+50
-29
lines changed

11 files changed

+50
-29
lines changed

src/components/Navbar.astro

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,22 @@ import DrawerToggler from "./DrawerToggler.astro";
66
import HorizontalContainer from "./HorizontalContainer.astro";
77
import ThemeSwitcher from "./ThemeSwitcher.astro";
88
import Dropdown from "./Dropdown.astro";
9-
import { getCollection } from "astro:content";
9+
import {
10+
getConceptPagesAlphabetical,
11+
getStartPagesByOrderParam,
12+
} from "../content/collections";
1013
import { conceptPagePath, startPagePath } from "../lib/utils";
1114
import Drawer from "./Drawer.astro";
1215
1316
const { title, githubUrl, navbarLinks } = site;
1417
15-
const startPages = (await getCollection("start")).map(
18+
const startPages = (await getStartPagesByOrderParam()).map(
1619
({ slug, data: { title } }) => {
1720
return { title, href: startPagePath(slug) };
1821
},
1922
);
2023
21-
const conceptPages = (await getCollection("concepts")).map(
24+
const conceptPages = (await getConceptPagesAlphabetical()).map(
2225
({ slug, data: { title } }) => {
2326
return { title, href: conceptPagePath(slug) };
2427
},

src/components/Pagination.astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
---
22
import Link from "./Link.astro";
3-
import { getCollection } from "astro:content";
43
import { startPagePath } from "../lib/utils";
4+
import { getStartPagesByOrderParam } from "../content/collections";
55
66
type Props = {
77
order: number;
88
};
99
1010
const { order } = Astro.props;
1111
12-
const startPages = await getCollection("start");
12+
const startPages = await getStartPagesByOrderParam();
13+
1314
const previousPage = startPages.find(
1415
({ data: { order: pageOrder } }) => pageOrder === order - 1,
1516
);

src/components/mdx/Languages.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const { languages } = site;
1717
<button
1818
@click={`language = "${lang}"`}
1919
class="rounded-lg px-1.5 py-1 text-sm font-semibold tracking-tight focus:outline-none dark:border-1.5 md:px-2 md:py-0.5 md:text-base lg:px-3 lg:py-1.5 lg:text-lg"
20-
x-bind:class='{ "border-primary bg-soft-gray dark:bg-darker-gray": language == "${lang}", "border-pale hover:text-primary dark:border-dark": language !== "${lang}" }'
20+
x-bind:class={`{ "border-primary bg-soft-gray dark:bg-darker-gray": language == "${lang}", "border-pale hover:text-primary dark:border-dark": language !== "${lang}" }`}
2121
>
2222
{lang}
2323
</button>

src/content/collections.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { getCollection } from "astro:content";
2+
3+
export const getStartPagesByOrderParam = async () => {
4+
return (await getCollection("start")).sort(
5+
({ data: { order: orderA } }, { data: { order: orderB } }) =>
6+
orderA - orderB,
7+
);
8+
};
9+
10+
export const getConceptPagesAlphabetical = () => {
11+
return getCollection("concepts");
12+
};

src/pages/concepts/[slug].astro

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
import type { GetStaticPaths } from "astro";
3-
import { getCollection } from "astro:content";
43
import Admonition from "../../components/mdx/Admonition.astro";
54
import NixStorePath from "../../components/mdx/NixStorePath.astro";
65
import Layout from "../../layouts/Layout.astro";
@@ -16,11 +15,10 @@ import A from "../../components/mdx/A.astro";
1615
import H2 from "../../components/mdx/H2.astro";
1716
import H3 from "../../components/mdx/H3.astro";
1817
import H4 from "../../components/mdx/H4.astro";
18+
import { getConceptPagesAlphabetical } from "../../content/collections";
1919
2020
export const getStaticPaths = (async () => {
21-
const conceptPages = await getCollection("concepts");
22-
23-
return conceptPages.map((page) => ({
21+
return (await getConceptPagesAlphabetical()).map((page) => ({
2422
params: { slug: page.slug },
2523
props: { page },
2624
}));
@@ -33,7 +31,7 @@ const {
3331
const { Content } = await page.render();
3432
3533
const relatedConceptPages: { title: string; href: string }[] = (
36-
await getCollection("concepts")
34+
await getConceptPagesAlphabetical()
3735
)
3836
.filter(({ slug }) => related.includes(slug))
3937
.map(({ slug, data: { title } }) => {

src/pages/concepts/index.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
---
2-
import { getCollection } from "astro:content";
32
import Layout from "../../layouts/Layout.astro";
43
import HorizontalContainer from "../../components/HorizontalContainer.astro";
54
import Hero from "../../components/Hero.astro";
65
import QuickStart from "../../components/QuickStart.astro";
76
import Grid3 from "../../components/Grid3.astro";
87
import HoverableLink from "../../components/HoverableLink.astro";
98
import { conceptPagePath } from "../../lib/utils";
9+
import { getConceptPagesAlphabetical } from "../../content/collections";
1010
1111
const title = "Concepts";
1212
const heroTitle = "Nix concepts";
1313
const description = "The whys and the hows of Nix";
1414
15-
const conceptPages = await getCollection("concepts");
15+
const conceptPages = await getConceptPagesAlphabetical();
1616
---
1717

1818
<Layout {title} {description}>

src/pages/llms-full.txt.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
import {
2+
getConceptPagesAlphabetical,
3+
getStartPagesByOrderParam,
4+
} from "../content/collections";
15
import { conceptPagePath, startPagePath } from "../lib/utils";
26
import { site } from "../site";
37
import { FORMATS } from "./llms.txt";
48
import type { APIRoute } from "astro";
5-
import { getCollection } from "astro:content";
69
import Handlebars from "handlebars";
710
import fs from "node:fs";
811
import path from "node:path";
@@ -17,8 +20,8 @@ const templateFile = fs.readFileSync(
1720
const template = Handlebars.compile(templateFile);
1821

1922
export const GET: APIRoute = async () => {
20-
const startPages = await getCollection("start");
21-
const conceptPages = await getCollection("concepts");
23+
const startPages = await getStartPagesByOrderParam();
24+
const conceptPages = await getConceptPagesAlphabetical();
2225

2326
const content = template({
2427
root,

src/pages/llms-small.txt.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import {
2+
getConceptPagesAlphabetical,
3+
getStartPagesByOrderParam,
4+
} from "../content/collections";
15
import { site } from "../site";
26
import { FORMATS } from "./llms.txt";
37
import type { APIRoute } from "astro";
4-
import { getCollection } from "astro:content";
58
import Handlebars from "handlebars";
69
import fs from "node:fs";
710
import path from "node:path";
@@ -16,8 +19,8 @@ const templateFile = fs.readFileSync(
1619
const template = Handlebars.compile(templateFile);
1720

1821
export const GET: APIRoute = async () => {
19-
const startPages = await getCollection("start");
20-
const conceptPages = await getCollection("concepts");
22+
const startPages = await getStartPagesByOrderParam();
23+
const conceptPages = await getConceptPagesAlphabetical();
2124

2225
const content = template({
2326
root,

src/pages/llms.txt.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import {
2+
getConceptPagesAlphabetical,
3+
getStartPagesByOrderParam,
4+
} from "../content/collections";
15
import { conceptPagePath, startPagePath } from "../lib/utils";
26
import { site } from "../site";
37
import type { APIRoute } from "astro";
4-
import { getCollection } from "astro:content";
58
import Handlebars from "handlebars";
69
import fs from "node:fs";
710
import path from "node:path";
@@ -37,8 +40,8 @@ const templateFile = fs.readFileSync(
3740
const template = Handlebars.compile(templateFile);
3841

3942
export const GET: APIRoute = async () => {
40-
const startPages = await getCollection("start");
41-
const conceptPages = await getCollection("concepts");
43+
const startPages = await getStartPagesByOrderParam();
44+
const conceptPages = await getConceptPagesAlphabetical();
4245

4346
const content = template({
4447
root,

src/pages/start/[slug].astro

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
import type { GetStaticPaths } from "astro";
3-
import { getCollection } from "astro:content";
43
import Admonition from "../../components/mdx/Admonition.astro";
54
import ExternalSources from "../../components/ExternalSources.astro";
65
import Language from "../../components/mdx/Language.astro";
@@ -17,11 +16,10 @@ import H4 from "../../components/mdx/H4.astro";
1716
import Pagination from "../../components/Pagination.astro";
1817
import Separator from "../../components/Separator.astro";
1918
import FeedbackBar from "../../components/FeedbackBar.astro";
19+
import { getStartPagesByOrderParam } from "../../content/collections";
2020
2121
export const getStaticPaths = (async () => {
22-
const startPages = await getCollection("start");
23-
24-
return startPages.map((page) => ({
22+
return (await getStartPagesByOrderParam()).map((page) => ({
2523
params: { slug: page.slug.substring(1) },
2624
props: { page },
2725
}));
@@ -33,7 +31,7 @@ const {
3331
} = page;
3432
const { Content } = await page.render();
3533
36-
const numQuickStartPages = (await getCollection("start")).length;
34+
const numQuickStartPages = (await getStartPagesByOrderParam()).length;
3735
---
3836

3937
<Layout {title}>

0 commit comments

Comments
 (0)