@specglass/core 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/defaults.d.ts +4 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +31 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/define-config.d.ts +17 -0
- package/dist/config/define-config.d.ts.map +1 -0
- package/dist/config/define-config.js +55 -0
- package/dist/config/define-config.js.map +1 -0
- package/dist/config/loader.d.ts +11 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +74 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +366 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +109 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/content/frontmatter-schema.d.ts +53 -0
- package/dist/content/frontmatter-schema.d.ts.map +1 -0
- package/dist/content/frontmatter-schema.js +27 -0
- package/dist/content/frontmatter-schema.js.map +1 -0
- package/dist/content/mdx-loader.d.ts +93 -0
- package/dist/content/mdx-loader.d.ts.map +1 -0
- package/dist/content/mdx-loader.js +97 -0
- package/dist/content/mdx-loader.js.map +1 -0
- package/dist/content/openapi-loader.d.ts +40 -0
- package/dist/content/openapi-loader.d.ts.map +1 -0
- package/dist/content/openapi-loader.js +58 -0
- package/dist/content/openapi-loader.js.map +1 -0
- package/dist/content/rehype-code-blocks.d.ts +15 -0
- package/dist/content/rehype-code-blocks.d.ts.map +1 -0
- package/dist/content/rehype-code-blocks.js +84 -0
- package/dist/content/rehype-code-blocks.js.map +1 -0
- package/dist/errors/specglass-error.d.ts +12 -0
- package/dist/errors/specglass-error.d.ts.map +1 -0
- package/dist/errors/specglass-error.js +19 -0
- package/dist/errors/specglass-error.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/integration.d.ts +41 -0
- package/dist/integration.d.ts.map +1 -0
- package/dist/integration.js +276 -0
- package/dist/integration.js.map +1 -0
- package/dist/navigation/builder.d.ts +24 -0
- package/dist/navigation/builder.d.ts.map +1 -0
- package/dist/navigation/builder.js +169 -0
- package/dist/navigation/builder.js.map +1 -0
- package/dist/navigation/index.d.ts +7 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/index.js +6 -0
- package/dist/navigation/index.js.map +1 -0
- package/dist/navigation/meta-parser.d.ts +9 -0
- package/dist/navigation/meta-parser.d.ts.map +1 -0
- package/dist/navigation/meta-parser.js +59 -0
- package/dist/navigation/meta-parser.js.map +1 -0
- package/dist/navigation/meta-schema.d.ts +77 -0
- package/dist/navigation/meta-schema.d.ts.map +1 -0
- package/dist/navigation/meta-schema.js +31 -0
- package/dist/navigation/meta-schema.js.map +1 -0
- package/dist/navigation/watcher.d.ts +44 -0
- package/dist/navigation/watcher.d.ts.map +1 -0
- package/dist/navigation/watcher.js +81 -0
- package/dist/navigation/watcher.js.map +1 -0
- package/dist/openapi/parser.d.ts +24 -0
- package/dist/openapi/parser.d.ts.map +1 -0
- package/dist/openapi/parser.js +53 -0
- package/dist/openapi/parser.js.map +1 -0
- package/dist/openapi/transformer.d.ts +19 -0
- package/dist/openapi/transformer.d.ts.map +1 -0
- package/dist/openapi/transformer.js +294 -0
- package/dist/openapi/transformer.js.map +1 -0
- package/dist/openapi/types.d.ts +109 -0
- package/dist/openapi/types.d.ts.map +1 -0
- package/dist/openapi/types.js +11 -0
- package/dist/openapi/types.js.map +1 -0
- package/dist/openapi/utils.d.ts +26 -0
- package/dist/openapi/utils.d.ts.map +1 -0
- package/dist/openapi/utils.js +34 -0
- package/dist/openapi/utils.js.map +1 -0
- package/dist/types/config.d.ts +7 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/navigation.d.ts +62 -0
- package/dist/types/navigation.d.ts.map +1 -0
- package/dist/types/navigation.js +2 -0
- package/dist/types/navigation.js.map +1 -0
- package/dist/virtual/modules.d.ts +34 -0
- package/dist/virtual/modules.d.ts.map +1 -0
- package/dist/virtual/modules.js +37 -0
- package/dist/virtual/modules.js.map +1 -0
- package/package.json +51 -0
- package/src/pages/[...slug].astro +55 -0
- package/src/pages/api-reference/[...slug].astro +67 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Identifier for the specglass config virtual module */
|
|
2
|
+
export const VIRTUAL_MODULE_ID = "virtual:specglass/config";
|
|
3
|
+
/** Identifier for the specglass navigation virtual module */
|
|
4
|
+
export const NAVIGATION_MODULE_ID = "virtual:specglass/navigation";
|
|
5
|
+
/** Identifier for the specglass OpenAPI data virtual module */
|
|
6
|
+
export const OPENAPI_DATA_MODULE_ID = "virtual:specglass/openapi-data";
|
|
7
|
+
/**
|
|
8
|
+
* Generate the JavaScript module content for `virtual:specglass/config`.
|
|
9
|
+
* Serializes the resolved config object into an exportable module string.
|
|
10
|
+
*
|
|
11
|
+
* @param config - The fully resolved and validated SpecglassConfig
|
|
12
|
+
* @returns JavaScript module source code exporting `config`
|
|
13
|
+
*/
|
|
14
|
+
export function generateConfigModuleContent(config) {
|
|
15
|
+
return `export const config = ${JSON.stringify(config)};`;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Generate the JavaScript module content for `virtual:specglass/navigation`.
|
|
19
|
+
*
|
|
20
|
+
* @param tree - The computed navigation tree to serialize into the virtual module.
|
|
21
|
+
* Defaults to an empty tree if not provided.
|
|
22
|
+
* @returns JavaScript module source code exporting `navigation`
|
|
23
|
+
*/
|
|
24
|
+
export function generateNavigationModuleContent(tree = { items: [] }) {
|
|
25
|
+
return `export const navigation = ${JSON.stringify(tree)};`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Generate the JavaScript module content for `virtual:specglass/openapi-data`.
|
|
29
|
+
*
|
|
30
|
+
* @param data - Array of parsed OpenAPI specs to serialize.
|
|
31
|
+
* Defaults to an empty array if not provided.
|
|
32
|
+
* @returns JavaScript module source code exporting `openApiData`
|
|
33
|
+
*/
|
|
34
|
+
export function generateOpenApiDataModuleContent(data = []) {
|
|
35
|
+
return `export const openApiData = ${JSON.stringify(data)};`;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=modules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../../src/virtual/modules.ts"],"names":[],"mappings":"AAIA,yDAAyD;AACzD,MAAM,CAAC,MAAM,iBAAiB,GAAG,0BAA0B,CAAC;AAE5D,6DAA6D;AAC7D,MAAM,CAAC,MAAM,oBAAoB,GAAG,8BAA8B,CAAC;AAEnE,+DAA+D;AAC/D,MAAM,CAAC,MAAM,sBAAsB,GAAG,gCAAgC,CAAC;AAGvE;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CAAC,MAAuB;IACjE,OAAO,yBAAyB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC;AAC5D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,+BAA+B,CAC7C,OAAuB,EAAE,KAAK,EAAE,EAAE,EAAE;IAEpC,OAAO,6BAA6B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;AAC9D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gCAAgC,CAC9C,OAA4B,EAAE;IAE9B,OAAO,8BAA8B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;AAC/D,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@specglass/core",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Astro integration, config system, content collections, and OpenAPI spec parsing for Specglass",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/Not-Diamond/ndocs.git",
|
|
10
|
+
"directory": "packages/core"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/Not-Diamond/ndocs#readme",
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./pages/*": "./src/pages/*"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"src/pages"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"lint": "eslint src/"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@astrojs/mdx": "^4.0",
|
|
34
|
+
"astro": "^5.17"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@redocly/openapi-core": "^2.18.1",
|
|
38
|
+
"@types/hast": "^3.0.4",
|
|
39
|
+
"acorn": "^8.14",
|
|
40
|
+
"astro-integration-kit": "^0.19.1",
|
|
41
|
+
"jiti": "^2.6",
|
|
42
|
+
"unist-util-visit": "^5.1.0",
|
|
43
|
+
"zod": "^3.23"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"astro": "^5.17",
|
|
47
|
+
"pagefind": "^1.4.0",
|
|
48
|
+
"typescript": "^5.5",
|
|
49
|
+
"vitest": "^3.0"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { getCollection, render } from "astro:content";
|
|
3
|
+
import { getSlugFromFilePath } from "@specglass/core";
|
|
4
|
+
import { config } from "virtual:specglass/config";
|
|
5
|
+
import { navigation } from "virtual:specglass/navigation";
|
|
6
|
+
import DocPage from "@specglass/theme-default/layouts/DocPage.astro";
|
|
7
|
+
import LandingPage from "@specglass/theme-default/layouts/LandingPage.astro";
|
|
8
|
+
|
|
9
|
+
export async function getStaticPaths() {
|
|
10
|
+
const docs = await getCollection("docs");
|
|
11
|
+
return docs.map((entry) => {
|
|
12
|
+
const slug = getSlugFromFilePath(entry.id);
|
|
13
|
+
return {
|
|
14
|
+
params: { slug: slug || undefined },
|
|
15
|
+
props: { entry },
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const { entry } = Astro.props;
|
|
21
|
+
|
|
22
|
+
if (!entry) {
|
|
23
|
+
return Astro.redirect("/404");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const { Content, headings } = await render(entry);
|
|
27
|
+
const title = entry.data.title ?? config.site?.title ?? "specglass";
|
|
28
|
+
const description = entry.data.description ?? config.site?.description ?? "";
|
|
29
|
+
const currentSlug = getSlugFromFilePath(entry.id) || "";
|
|
30
|
+
const layout = (entry.data as Record<string, unknown>).layout as string | undefined;
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
{
|
|
34
|
+
layout === "landing" ? (
|
|
35
|
+
<LandingPage
|
|
36
|
+
title={title}
|
|
37
|
+
description={description}
|
|
38
|
+
frontmatter={entry.data}
|
|
39
|
+
navigation={navigation}
|
|
40
|
+
>
|
|
41
|
+
<Content />
|
|
42
|
+
</LandingPage>
|
|
43
|
+
) : (
|
|
44
|
+
<DocPage
|
|
45
|
+
title={title}
|
|
46
|
+
description={description}
|
|
47
|
+
frontmatter={entry.data}
|
|
48
|
+
navigation={navigation}
|
|
49
|
+
headings={headings}
|
|
50
|
+
currentSlug={currentSlug}
|
|
51
|
+
>
|
|
52
|
+
<Content />
|
|
53
|
+
</DocPage>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* API Reference route page.
|
|
4
|
+
* Generates one page per endpoint from the virtual:specglass/openapi-data module.
|
|
5
|
+
* Maps parsed OpenAPI data into ApiReferencePage layout props.
|
|
6
|
+
*/
|
|
7
|
+
import type { ParsedOpenApiSpec, ApiEndpoint } from "@specglass/core";
|
|
8
|
+
import { buildEndpointSlug } from "@specglass/core";
|
|
9
|
+
import { config } from "virtual:specglass/config";
|
|
10
|
+
import { navigation } from "virtual:specglass/navigation";
|
|
11
|
+
import { openApiData } from "virtual:specglass/openapi-data";
|
|
12
|
+
import ApiReferencePage from "@specglass/theme-default/layouts/ApiReferencePage.astro";
|
|
13
|
+
|
|
14
|
+
export async function getStaticPaths() {
|
|
15
|
+
const allSpecs = openApiData as ParsedOpenApiSpec[];
|
|
16
|
+
const paths: Array<{
|
|
17
|
+
params: { slug: string | undefined };
|
|
18
|
+
props: {
|
|
19
|
+
endpoint: ApiEndpoint;
|
|
20
|
+
allEndpoints: ApiEndpoint[];
|
|
21
|
+
specInfo: ParsedOpenApiSpec["info"];
|
|
22
|
+
securitySchemes: ParsedOpenApiSpec["securitySchemes"];
|
|
23
|
+
};
|
|
24
|
+
}> = [];
|
|
25
|
+
|
|
26
|
+
for (const spec of allSpecs) {
|
|
27
|
+
for (const endpoint of spec.endpoints) {
|
|
28
|
+
const slug = buildEndpointSlug(endpoint);
|
|
29
|
+
paths.push({
|
|
30
|
+
params: { slug },
|
|
31
|
+
props: {
|
|
32
|
+
endpoint,
|
|
33
|
+
allEndpoints: spec.endpoints,
|
|
34
|
+
specInfo: spec.info,
|
|
35
|
+
securitySchemes: spec.securitySchemes,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Index page: render the first endpoint at /api-reference
|
|
41
|
+
if (spec.endpoints.length > 0) {
|
|
42
|
+
paths.push({
|
|
43
|
+
params: { slug: undefined },
|
|
44
|
+
props: {
|
|
45
|
+
endpoint: spec.endpoints[0],
|
|
46
|
+
allEndpoints: spec.endpoints,
|
|
47
|
+
specInfo: spec.info,
|
|
48
|
+
securitySchemes: spec.securitySchemes,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return paths;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const { endpoint, allEndpoints, specInfo, securitySchemes } = Astro.props;
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
<ApiReferencePage
|
|
61
|
+
endpoint={endpoint}
|
|
62
|
+
navigation={navigation}
|
|
63
|
+
config={config}
|
|
64
|
+
allEndpoints={allEndpoints}
|
|
65
|
+
specInfo={specInfo}
|
|
66
|
+
securitySchemes={securitySchemes}
|
|
67
|
+
/>
|