Skip to content

Commit 173f698

Browse files
committed
refactor: new interface
1 parent e0da384 commit 173f698

69 files changed

Lines changed: 9720 additions & 159 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.astro/content-assets.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default new Map();

.astro/content-modules.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default new Map();

.astro/content.d.ts

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
declare module 'astro:content' {
2+
interface Render {
3+
'.mdx': Promise<{
4+
Content: import('astro').MDXContent;
5+
headings: import('astro').MarkdownHeading[];
6+
remarkPluginFrontmatter: Record<string, any>;
7+
components: import('astro').MDXInstance<{}>['components'];
8+
}>;
9+
}
10+
}
11+
12+
declare module 'astro:content' {
13+
export interface RenderResult {
14+
Content: import('astro/runtime/server/index.js').AstroComponentFactory;
15+
headings: import('astro').MarkdownHeading[];
16+
remarkPluginFrontmatter: Record<string, any>;
17+
}
18+
interface Render {
19+
'.md': Promise<RenderResult>;
20+
}
21+
22+
export interface RenderedContent {
23+
html: string;
24+
metadata?: {
25+
imagePaths: Array<string>;
26+
[key: string]: unknown;
27+
};
28+
}
29+
}
30+
31+
declare module 'astro:content' {
32+
type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
33+
34+
export type CollectionKey = keyof AnyEntryMap;
35+
export type CollectionEntry<C extends CollectionKey> = Flatten<AnyEntryMap[C]>;
36+
37+
export type ContentCollectionKey = keyof ContentEntryMap;
38+
export type DataCollectionKey = keyof DataEntryMap;
39+
40+
type AllValuesOf<T> = T extends any ? T[keyof T] : never;
41+
type ValidContentEntrySlug<C extends keyof ContentEntryMap> = AllValuesOf<
42+
ContentEntryMap[C]
43+
>['slug'];
44+
45+
export type ReferenceDataEntry<
46+
C extends CollectionKey,
47+
E extends keyof DataEntryMap[C] = string,
48+
> = {
49+
collection: C;
50+
id: E;
51+
};
52+
export type ReferenceContentEntry<
53+
C extends keyof ContentEntryMap,
54+
E extends ValidContentEntrySlug<C> | (string & {}) = string,
55+
> = {
56+
collection: C;
57+
slug: E;
58+
};
59+
export type ReferenceLiveEntry<C extends keyof LiveContentConfig['collections']> = {
60+
collection: C;
61+
id: string;
62+
};
63+
64+
/** @deprecated Use `getEntry` instead. */
65+
export function getEntryBySlug<
66+
C extends keyof ContentEntryMap,
67+
E extends ValidContentEntrySlug<C> | (string & {}),
68+
>(
69+
collection: C,
70+
// Note that this has to accept a regular string too, for SSR
71+
entrySlug: E,
72+
): E extends ValidContentEntrySlug<C>
73+
? Promise<CollectionEntry<C>>
74+
: Promise<CollectionEntry<C> | undefined>;
75+
76+
/** @deprecated Use `getEntry` instead. */
77+
export function getDataEntryById<C extends keyof DataEntryMap, E extends keyof DataEntryMap[C]>(
78+
collection: C,
79+
entryId: E,
80+
): Promise<CollectionEntry<C>>;
81+
82+
export function getCollection<C extends keyof AnyEntryMap, E extends CollectionEntry<C>>(
83+
collection: C,
84+
filter?: (entry: CollectionEntry<C>) => entry is E,
85+
): Promise<E[]>;
86+
export function getCollection<C extends keyof AnyEntryMap>(
87+
collection: C,
88+
filter?: (entry: CollectionEntry<C>) => unknown,
89+
): Promise<CollectionEntry<C>[]>;
90+
91+
export function getLiveCollection<C extends keyof LiveContentConfig['collections']>(
92+
collection: C,
93+
filter?: LiveLoaderCollectionFilterType<C>,
94+
): Promise<
95+
import('astro').LiveDataCollectionResult<LiveLoaderDataType<C>, LiveLoaderErrorType<C>>
96+
>;
97+
98+
export function getEntry<
99+
C extends keyof ContentEntryMap,
100+
E extends ValidContentEntrySlug<C> | (string & {}),
101+
>(
102+
entry: ReferenceContentEntry<C, E>,
103+
): E extends ValidContentEntrySlug<C>
104+
? Promise<CollectionEntry<C>>
105+
: Promise<CollectionEntry<C> | undefined>;
106+
export function getEntry<
107+
C extends keyof DataEntryMap,
108+
E extends keyof DataEntryMap[C] | (string & {}),
109+
>(
110+
entry: ReferenceDataEntry<C, E>,
111+
): E extends keyof DataEntryMap[C]
112+
? Promise<DataEntryMap[C][E]>
113+
: Promise<CollectionEntry<C> | undefined>;
114+
export function getEntry<
115+
C extends keyof ContentEntryMap,
116+
E extends ValidContentEntrySlug<C> | (string & {}),
117+
>(
118+
collection: C,
119+
slug: E,
120+
): E extends ValidContentEntrySlug<C>
121+
? Promise<CollectionEntry<C>>
122+
: Promise<CollectionEntry<C> | undefined>;
123+
export function getEntry<
124+
C extends keyof DataEntryMap,
125+
E extends keyof DataEntryMap[C] | (string & {}),
126+
>(
127+
collection: C,
128+
id: E,
129+
): E extends keyof DataEntryMap[C]
130+
? string extends keyof DataEntryMap[C]
131+
? Promise<DataEntryMap[C][E]> | undefined
132+
: Promise<DataEntryMap[C][E]>
133+
: Promise<CollectionEntry<C> | undefined>;
134+
export function getLiveEntry<C extends keyof LiveContentConfig['collections']>(
135+
collection: C,
136+
filter: string | LiveLoaderEntryFilterType<C>,
137+
): Promise<import('astro').LiveDataEntryResult<LiveLoaderDataType<C>, LiveLoaderErrorType<C>>>;
138+
139+
/** Resolve an array of entry references from the same collection */
140+
export function getEntries<C extends keyof ContentEntryMap>(
141+
entries: ReferenceContentEntry<C, ValidContentEntrySlug<C>>[],
142+
): Promise<CollectionEntry<C>[]>;
143+
export function getEntries<C extends keyof DataEntryMap>(
144+
entries: ReferenceDataEntry<C, keyof DataEntryMap[C]>[],
145+
): Promise<CollectionEntry<C>[]>;
146+
147+
export function render<C extends keyof AnyEntryMap>(
148+
entry: AnyEntryMap[C][string],
149+
): Promise<RenderResult>;
150+
151+
export function reference<C extends keyof AnyEntryMap>(
152+
collection: C,
153+
): import('astro/zod').ZodEffects<
154+
import('astro/zod').ZodString,
155+
C extends keyof ContentEntryMap
156+
? ReferenceContentEntry<C, ValidContentEntrySlug<C>>
157+
: ReferenceDataEntry<C, keyof DataEntryMap[C]>
158+
>;
159+
// Allow generic `string` to avoid excessive type errors in the config
160+
// if `dev` is not running to update as you edit.
161+
// Invalid collection names will be caught at build time.
162+
export function reference<C extends string>(
163+
collection: C,
164+
): import('astro/zod').ZodEffects<import('astro/zod').ZodString, never>;
165+
166+
type ReturnTypeOrOriginal<T> = T extends (...args: any[]) => infer R ? R : T;
167+
type InferEntrySchema<C extends keyof AnyEntryMap> = import('astro/zod').infer<
168+
ReturnTypeOrOriginal<Required<ContentConfig['collections'][C]>['schema']>
169+
>;
170+
171+
type ContentEntryMap = {
172+
173+
};
174+
175+
type DataEntryMap = {
176+
177+
};
178+
179+
type AnyEntryMap = ContentEntryMap & DataEntryMap;
180+
181+
type ExtractLoaderTypes<T> = T extends import('astro/loaders').LiveLoader<
182+
infer TData,
183+
infer TEntryFilter,
184+
infer TCollectionFilter,
185+
infer TError
186+
>
187+
? { data: TData; entryFilter: TEntryFilter; collectionFilter: TCollectionFilter; error: TError }
188+
: { data: never; entryFilter: never; collectionFilter: never; error: never };
189+
type ExtractDataType<T> = ExtractLoaderTypes<T>['data'];
190+
type ExtractEntryFilterType<T> = ExtractLoaderTypes<T>['entryFilter'];
191+
type ExtractCollectionFilterType<T> = ExtractLoaderTypes<T>['collectionFilter'];
192+
type ExtractErrorType<T> = ExtractLoaderTypes<T>['error'];
193+
194+
type LiveLoaderDataType<C extends keyof LiveContentConfig['collections']> =
195+
LiveContentConfig['collections'][C]['schema'] extends undefined
196+
? ExtractDataType<LiveContentConfig['collections'][C]['loader']>
197+
: import('astro/zod').infer<
198+
Exclude<LiveContentConfig['collections'][C]['schema'], undefined>
199+
>;
200+
type LiveLoaderEntryFilterType<C extends keyof LiveContentConfig['collections']> =
201+
ExtractEntryFilterType<LiveContentConfig['collections'][C]['loader']>;
202+
type LiveLoaderCollectionFilterType<C extends keyof LiveContentConfig['collections']> =
203+
ExtractCollectionFilterType<LiveContentConfig['collections'][C]['loader']>;
204+
type LiveLoaderErrorType<C extends keyof LiveContentConfig['collections']> = ExtractErrorType<
205+
LiveContentConfig['collections'][C]['loader']
206+
>;
207+
208+
export type ContentConfig = typeof import("./../src/content.config.mjs");
209+
export type LiveContentConfig = never;
210+
}

.astro/data-store.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[["Map",1,2],"meta::meta",["Map",3,4,5,6],"astro-version","5.16.11","astro-config-digest","{\"root\":{},\"srcDir\":{},\"publicDir\":{},\"outDir\":{},\"cacheDir\":{},\"site\":\"https://hlop3z.github.io\",\"compressHTML\":true,\"base\":\"/coding-algorithms\",\"trailingSlash\":\"ignore\",\"output\":\"static\",\"scopedStyleStrategy\":\"attribute\",\"build\":{\"format\":\"directory\",\"client\":{},\"server\":{},\"assets\":\"_assets\",\"serverEntry\":\"entry.mjs\",\"redirects\":true,\"inlineStylesheets\":\"auto\",\"concurrency\":1},\"server\":{\"open\":false,\"host\":false,\"port\":4321,\"streaming\":true,\"allowedHosts\":[]},\"redirects\":{},\"image\":{\"endpoint\":{\"route\":\"/_image\"},\"service\":{\"entrypoint\":\"astro/assets/services/sharp\",\"config\":{}},\"domains\":[],\"remotePatterns\":[],\"responsiveStyles\":false},\"devToolbar\":{\"enabled\":true},\"markdown\":{\"syntaxHighlight\":false,\"shikiConfig\":{\"langs\":[],\"langAlias\":{},\"theme\":\"github-dark\",\"themes\":{},\"wrap\":false,\"transformers\":[]},\"remarkPlugins\":[],\"rehypePlugins\":[[null,{\"themes\":[\"github-dark\",\"github-light\"],\"styleOverrides\":{\"borderRadius\":\"0.5rem\"}}]],\"remarkRehype\":{},\"gfm\":true,\"smartypants\":true},\"security\":{\"checkOrigin\":true,\"allowedDomains\":[]},\"env\":{\"schema\":{},\"validateSecrets\":false},\"experimental\":{\"clientPrerender\":false,\"contentIntellisense\":false,\"headingIdCompat\":false,\"preserveScriptOrder\":false,\"liveContentCollections\":false,\"csp\":false,\"staticImportMetaEnv\":false,\"chromeDevtoolsWorkspace\":false,\"failOnPrerenderConflict\":false,\"svgo\":false},\"legacy\":{\"collections\":false}}"]

.astro/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"_variables": {
3+
"lastUpdateCheck": 1768715091407
4+
}
5+
}

.astro/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="astro/client" />

.github/workflows/deploy.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup pnpm
25+
uses: pnpm/action-setup@v4
26+
with:
27+
version: 10
28+
29+
- name: Setup Node
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: '20'
33+
cache: 'pnpm'
34+
35+
- name: Install dependencies
36+
run: pnpm install --frozen-lockfile
37+
38+
- name: Build
39+
run: pnpm build
40+
41+
- name: Upload artifact
42+
uses: actions/upload-pages-artifact@v3
43+
with:
44+
path: ./dist
45+
46+
deploy:
47+
needs: build
48+
runs-on: ubuntu-latest
49+
environment:
50+
name: github-pages
51+
url: ${{ steps.deployment.outputs.page_url }}
52+
steps:
53+
- name: Deploy to GitHub Pages
54+
id: deployment
55+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)