Skip to content

Commit 720e797

Browse files
authored
Merge pull request #476 from DeterminateSystems/lucperkins/gtm-130-llmstxt-for-zero-to-nix
GTM-130: Add `llms*.txt`
2 parents 6b48c0b + 68c2cbd commit 720e797

File tree

16 files changed

+374
-13
lines changed

16 files changed

+374
-13
lines changed

.github/workflows/update-flake-lock.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
committer: github-actions[bot] github-actions[bot]@users.noreply.github.com
6060
assignees: lucperkins
6161
reviewers: lucperkins
62-
labels:
62+
labels: |
6363
automated
6464
templates
6565
update

.npmrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
auto-install-peers = true
21
shamefully-hoist = true

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ pnpm-lock.yaml
77
**/*.mdx
88
src/components/Posthog.astro
99
**/*.lock
10+
**/*.hbs

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"astro-expressive-code": "^0.38.3",
3535
"astro-icon": "^1.1.5",
3636
"astro-seo": "^0.8.4",
37+
"handlebars": "^4.7.8",
3738
"marked": "^12.0.2",
3839
"posthog-js": "^1.266.0",
3940
"react": "^18.3.1",

pnpm-lock.yaml

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
overrides:
2-
devalue@<5.3.2: '>=5.3.2'
2+
devalue@<5.3.2: ">=5.3.2"

src/components/Footer.astro

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,39 @@ const currentYear = new Date().getFullYear();
77

88
<footer>
99
<HorizontalContainer>
10-
<div class="flex justify-end pb-16 pt-12">
11-
<p
12-
class="tracking-tight text-gray dark:text-gray md:text-base lg:text-lg"
13-
>
14-
Copyright &copy; {currentYear}
15-
<Link href="https://determinate.systems" class="hover:text-primary">
16-
Determinate Systems, Inc.
17-
</Link>
18-
</p>
10+
<div class="pb-16 pt-12">
11+
<div class="flex items-center justify-between">
12+
<div class="flex items-center gap-4">
13+
<strong>AI tools</strong>
14+
<ul class="flex items-center gap-2">
15+
{
16+
["llms.txt", "llms-small.txt", "llms-full.txt"].map((file) => (
17+
<li>
18+
<a
19+
href={`/${file}`}
20+
class="text-sm text-gray duration-hover hover:text-nix-light-blue dark:hover:text-orange"
21+
>
22+
<code>{file}</code>
23+
</a>
24+
</li>
25+
))
26+
}
27+
</ul>
28+
</div>
29+
<div>
30+
<p
31+
class="tracking-tight text-gray dark:text-gray md:text-base lg:text-lg"
32+
>
33+
Copyright &copy; {currentYear}
34+
<Link
35+
href="https://determinate.systems"
36+
class="duration-hover hover:text-primary dark:hover:text-orange"
37+
>
38+
Determinate Systems, Inc.
39+
</Link>
40+
</p>
41+
</div>
42+
</div>
1943
</div>
2044
</HorizontalContainer>
2145
</footer>

src/components/FormattedDate.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const { date } = Astro.props;
88

99
<time datetime={date.toISOString()}>
1010
{
11-
date.toLocaleDateString("en-us", {
11+
date.toLocaleDateString("en-US", {
1212
year: "numeric",
1313
month: "short",
1414
day: "numeric",

src/lib/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@ export const startPagePath = (slug: string): string => {
1515
const pagePath = (collection: string, slug: string): string => {
1616
return `/${collection}/${slug}`;
1717
};
18+
19+
export const formatDate = (date: Date): string => {
20+
return date.toLocaleDateString("en-US", {
21+
year: "numeric",
22+
month: "long",
23+
day: "numeric",
24+
});
25+
};

src/pages/llms-full.txt.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { conceptPagePath, startPagePath } from "../lib/utils";
2+
import { site } from "../site";
3+
import { FORMATS } from "./llms.txt";
4+
import type { APIRoute } from "astro";
5+
import { getCollection } from "astro:content";
6+
import Handlebars from "handlebars";
7+
import fs from "node:fs";
8+
import path from "node:path";
9+
10+
const { url: root, title, description: tagline, llms } = site;
11+
12+
const templateFile = fs.readFileSync(
13+
path.join(process.cwd(), "src/templates/llms-full.txt.hbs"),
14+
"utf-8",
15+
);
16+
17+
const template = Handlebars.compile(templateFile);
18+
19+
export const GET: APIRoute = async () => {
20+
const startPages = await getCollection("start");
21+
const conceptPages = await getCollection("concepts");
22+
23+
const content = template({
24+
root,
25+
title,
26+
system:
27+
"This is the complete documentation for Zero to Nix, including the learning journey (start) and concept pages.",
28+
instructions:
29+
"Learning journey (start) and concept page items begin and end with a --- and all page titles are in bold.",
30+
tagline,
31+
description: llms.description,
32+
startPages: startPages.map(({ data: { title }, slug, body }) => ({
33+
title,
34+
href: `${root}/${startPagePath(slug)}`,
35+
content: body,
36+
})),
37+
conceptPages: conceptPages.map(({ data: { title }, slug, body }) => ({
38+
title,
39+
href: `${root}/${conceptPagePath(slug)}`,
40+
content: body,
41+
})),
42+
otherFormats: [FORMATS.small, FORMATS.standard],
43+
});
44+
45+
return new Response(content, {
46+
headers: {
47+
"Content-Type": "text/plain; charset=utf-8",
48+
},
49+
});
50+
};
51+
52+
export const prerender = true;

0 commit comments

Comments
 (0)