fix(ci): proper types
This commit is contained in:
parent
28c3cfcf6d
commit
16850cf468
9 changed files with 607 additions and 15 deletions
|
|
@ -30,7 +30,7 @@ const lines = Astro.props.code.trim().split(/\r?\n/);
|
|||
<pre
|
||||
class="pseudocode-block">
|
||||
{lines.map((line, i) => (
|
||||
<div class="pseudocode-line" key={i}>
|
||||
<div class="pseudocode-line">
|
||||
<span class="line-number">{i + 1}.</span>
|
||||
<span class="line-content">{line}</span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ if (post?.collection === "git" && post?.slug) {
|
|||
documentTitle = `${post.slug}`;
|
||||
}
|
||||
|
||||
const topicColor = getTopicColor(post.collection);
|
||||
const topicColor = getTopicColor(post?.collection);
|
||||
---
|
||||
|
||||
<BaseLayout title={documentTitle} description={description}>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import BaseLayout from "../layouts/BaseLayout.astro";
|
|||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const base = (window && window.TERMINAL_PROMPT) || "barrett@ruth:~$ ";
|
||||
const base = "barrett@ruth:~$ ";
|
||||
const el = document.querySelector(".terminal-prompt");
|
||||
if (!el) return;
|
||||
|
||||
|
|
@ -26,11 +26,7 @@ import BaseLayout from "../layouts/BaseLayout.astro";
|
|||
})();
|
||||
};
|
||||
|
||||
if (window && typeof window.clearPrompt === "function") {
|
||||
window.clearPrompt(250, type);
|
||||
} else {
|
||||
type();
|
||||
}
|
||||
type();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,19 @@
|
|||
---
|
||||
import { getCollection } from "astro:content";
|
||||
import { getCollection, type CollectionEntry } from "astro:content";
|
||||
import PostLayout from "../../layouts/PostLayout.astro";
|
||||
import * as collections from "../../content/config";
|
||||
import type { PostCollection, AnyCollectionEntry } from "../../types";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const categories = Object.keys(collections.collections).filter(
|
||||
(c) => c !== "git" && c !== "gists",
|
||||
);
|
||||
) as PostCollection[];
|
||||
|
||||
const entries: Array<{
|
||||
params: { category: string; slug: string };
|
||||
props: { post: AnyCollectionEntry };
|
||||
}> = [];
|
||||
|
||||
const entries = [];
|
||||
for (const category of categories) {
|
||||
const docs = await getCollection(category);
|
||||
for (const doc of docs) {
|
||||
|
|
@ -21,6 +26,10 @@ export async function getStaticPaths() {
|
|||
return entries;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
post: AnyCollectionEntry;
|
||||
}
|
||||
|
||||
const { post } = Astro.props;
|
||||
const category = Astro.params.category;
|
||||
const { Content } = await post.render();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import BaseLayout from "../../layouts/BaseLayout.astro";
|
|||
import { getCollection } from "astro:content";
|
||||
import { sortItem } from "../../utils/sort.js";
|
||||
import * as collections from "../../content/config";
|
||||
import type { PostCollection } from "../../types";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
return Object.keys(collections.collections)
|
||||
|
|
@ -12,7 +13,7 @@ export async function getStaticPaths() {
|
|||
}));
|
||||
}
|
||||
|
||||
const category = Astro.params.category;
|
||||
const category = Astro.params.category as PostCollection;
|
||||
const title = "Barrett Ruth";
|
||||
|
||||
const posts = await getCollection(category);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,27 @@
|
|||
---
|
||||
import BaseLayout from "../layouts/BaseLayout.astro";
|
||||
import { sortItem } from "../utils/sort.js";
|
||||
import { getCollection } from "astro:content";
|
||||
import { getCollection, type CollectionEntry } from "astro:content";
|
||||
import type { PostCollection } from "../types";
|
||||
|
||||
const title = "Barrett Ruth";
|
||||
const CATS = ["algorithms", "software", "meditations", "autonomous-racing"];
|
||||
const CATS: PostCollection[] = [
|
||||
"algorithms",
|
||||
"software",
|
||||
"meditations",
|
||||
"autonomous-racing",
|
||||
];
|
||||
|
||||
const postsByCategory = {};
|
||||
type PostData = {
|
||||
id: string;
|
||||
slug: string;
|
||||
data: {
|
||||
title: string;
|
||||
date: string | null;
|
||||
};
|
||||
};
|
||||
|
||||
const postsByCategory: Record<string, PostData[]> = {};
|
||||
for (const c of CATS) {
|
||||
const entries = await getCollection(c);
|
||||
entries.sort(sortItem);
|
||||
|
|
|
|||
18
src/types.ts
Normal file
18
src/types.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import type { CollectionEntry } from "astro:content";
|
||||
|
||||
export type CollectionKey =
|
||||
| "algorithms"
|
||||
| "software"
|
||||
| "meditations"
|
||||
| "autonomous-racing"
|
||||
| "git"
|
||||
| "gists";
|
||||
export type PostCollection = Exclude<CollectionKey, "git" | "gists">;
|
||||
|
||||
export type AnyCollectionEntry =
|
||||
| CollectionEntry<"algorithms">
|
||||
| CollectionEntry<"software">
|
||||
| CollectionEntry<"meditations">
|
||||
| CollectionEntry<"autonomous-racing">
|
||||
| CollectionEntry<"git">
|
||||
| CollectionEntry<"gists">;
|
||||
Loading…
Add table
Add a link
Reference in a new issue