File tree Expand file tree Collapse file tree 11 files changed +50
-29
lines changed
Expand file tree Collapse file tree 11 files changed +50
-29
lines changed Original file line number Diff line number Diff line change @@ -6,19 +6,22 @@ import DrawerToggler from "./DrawerToggler.astro";
66import HorizontalContainer from " ./HorizontalContainer.astro" ;
77import ThemeSwitcher from " ./ThemeSwitcher.astro" ;
88import Dropdown from " ./Dropdown.astro" ;
9- import { getCollection } from " astro:content" ;
9+ import {
10+ getConceptPagesAlphabetical ,
11+ getStartPagesByOrderParam ,
12+ } from " ../content/collections" ;
1013import { conceptPagePath , startPagePath } from " ../lib/utils" ;
1114import Drawer from " ./Drawer.astro" ;
1215
1316const { 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 },
Original file line number Diff line number Diff line change 11---
22import Link from " ./Link.astro" ;
3- import { getCollection } from " astro:content" ;
43import { startPagePath } from " ../lib/utils" ;
4+ import { getStartPagesByOrderParam } from " ../content/collections" ;
55
66type Props = {
77 order: number ;
88};
99
1010const { order } = Astro .props ;
1111
12- const startPages = await getCollection (" start" );
12+ const startPages = await getStartPagesByOrderParam ();
13+
1314const previousPage = startPages .find (
1415 ({ data : { order : pageOrder } }) => pageOrder === order - 1 ,
1516);
Original file line number Diff line number Diff 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 >
Original file line number Diff line number Diff line change 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+ } ;
Original file line number Diff line number Diff line change 11---
22import type { GetStaticPaths } from " astro" ;
3- import { getCollection } from " astro:content" ;
43import Admonition from " ../../components/mdx/Admonition.astro" ;
54import NixStorePath from " ../../components/mdx/NixStorePath.astro" ;
65import Layout from " ../../layouts/Layout.astro" ;
@@ -16,11 +15,10 @@ import A from "../../components/mdx/A.astro";
1615import H2 from " ../../components/mdx/H2.astro" ;
1716import H3 from " ../../components/mdx/H3.astro" ;
1817import H4 from " ../../components/mdx/H4.astro" ;
18+ import { getConceptPagesAlphabetical } from " ../../content/collections" ;
1919
2020export 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 {
3331const { Content } = await page .render ();
3432
3533const relatedConceptPages: { title: string ; href: string }[] = (
36- await getCollection ( " concepts " )
34+ await getConceptPagesAlphabetical ( )
3735)
3836 .filter (({ slug }) => related .includes (slug ))
3937 .map (({ slug , data : { title } }) => {
Original file line number Diff line number Diff line change 11---
2- import { getCollection } from " astro:content" ;
32import Layout from " ../../layouts/Layout.astro" ;
43import HorizontalContainer from " ../../components/HorizontalContainer.astro" ;
54import Hero from " ../../components/Hero.astro" ;
65import QuickStart from " ../../components/QuickStart.astro" ;
76import Grid3 from " ../../components/Grid3.astro" ;
87import HoverableLink from " ../../components/HoverableLink.astro" ;
98import { conceptPagePath } from " ../../lib/utils" ;
9+ import { getConceptPagesAlphabetical } from " ../../content/collections" ;
1010
1111const title = " Concepts" ;
1212const heroTitle = " Nix concepts" ;
1313const 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 }>
Original file line number Diff line number Diff line change 1+ import {
2+ getConceptPagesAlphabetical ,
3+ getStartPagesByOrderParam ,
4+ } from "../content/collections" ;
15import { conceptPagePath , startPagePath } from "../lib/utils" ;
26import { site } from "../site" ;
37import { FORMATS } from "./llms.txt" ;
48import type { APIRoute } from "astro" ;
5- import { getCollection } from "astro:content" ;
69import Handlebars from "handlebars" ;
710import fs from "node:fs" ;
811import path from "node:path" ;
@@ -17,8 +20,8 @@ const templateFile = fs.readFileSync(
1720const template = Handlebars . compile ( templateFile ) ;
1821
1922export 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,
Original file line number Diff line number Diff line change 1+ import {
2+ getConceptPagesAlphabetical ,
3+ getStartPagesByOrderParam ,
4+ } from "../content/collections" ;
15import { site } from "../site" ;
26import { FORMATS } from "./llms.txt" ;
37import type { APIRoute } from "astro" ;
4- import { getCollection } from "astro:content" ;
58import Handlebars from "handlebars" ;
69import fs from "node:fs" ;
710import path from "node:path" ;
@@ -16,8 +19,8 @@ const templateFile = fs.readFileSync(
1619const template = Handlebars . compile ( templateFile ) ;
1720
1821export 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,
Original file line number Diff line number Diff line change 1+ import {
2+ getConceptPagesAlphabetical ,
3+ getStartPagesByOrderParam ,
4+ } from "../content/collections" ;
15import { conceptPagePath , startPagePath } from "../lib/utils" ;
26import { site } from "../site" ;
37import type { APIRoute } from "astro" ;
4- import { getCollection } from "astro:content" ;
58import Handlebars from "handlebars" ;
69import fs from "node:fs" ;
710import path from "node:path" ;
@@ -37,8 +40,8 @@ const templateFile = fs.readFileSync(
3740const template = Handlebars . compile ( templateFile ) ;
3841
3942export 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,
Original file line number Diff line number Diff line change 11---
22import type { GetStaticPaths } from " astro" ;
3- import { getCollection } from " astro:content" ;
43import Admonition from " ../../components/mdx/Admonition.astro" ;
54import ExternalSources from " ../../components/ExternalSources.astro" ;
65import Language from " ../../components/mdx/Language.astro" ;
@@ -17,11 +16,10 @@ import H4 from "../../components/mdx/H4.astro";
1716import Pagination from " ../../components/Pagination.astro" ;
1817import Separator from " ../../components/Separator.astro" ;
1918import FeedbackBar from " ../../components/FeedbackBar.astro" ;
19+ import { getStartPagesByOrderParam } from " ../../content/collections" ;
2020
2121export 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 ;
3432const { Content } = await page .render ();
3533
36- const numQuickStartPages = (await getCollection ( " start " )).length ;
34+ const numQuickStartPages = (await getStartPagesByOrderParam ( )).length ;
3735---
3836
3937<Layout {title }>
You can’t perform that action at this time.
0 commit comments