Skip to content

Commit

Permalink
Update reference.ts to actually set context for resource pages
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-balitskyi committed Aug 22, 2024
1 parent d5f7a9b commit 2d3641d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/lib/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type Metalsmith from 'metalsmith'

import {
type EndpointTemplateContext,
type ResourceTemplateContext,
setApiResourceTemplateContext,
setEndpointTemplateContext,
} from './template-context.js'

Expand All @@ -12,7 +14,8 @@ const baseUrl = 'https://docs.seam.co/latest/'

type Metadata = Partial<Pick<Blueprint, 'routes' | 'resources'>>

type File = EndpointTemplateContext & { layout: string }
type File = EndpointTemplateContext &
ResourceTemplateContext & { layout: string }

export const reference = (
files: Metalsmith.Files,
Expand All @@ -26,14 +29,22 @@ export const reference = (
}

for (const route of metadata.routes ?? []) {
const k = `api${route.path}/README.md`
files[k] = {
contents: Buffer.from('\n'),
}
const file = files[k] as unknown as File
file.layout = 'api-resource.hbs'
setApiResourceTemplateContext(file, route, metadata)

for (const endpoint of route.endpoints) {
const k = `api${endpoint.path}.md`
files[k] = {
contents: Buffer.from('\n'),
}
const file = files[k] as unknown as File
file.layout = 'api-reference.hbs'
setEndpointTemplateContext(file, endpoint, metadata)
setEndpointTemplateContext(file, endpoint)

for (const sdk of sdks) {
const k = `sdk/${sdk}${endpoint.path}.md`
Expand All @@ -42,7 +53,7 @@ export const reference = (
}
const file = files[k] as unknown as File
file.layout = 'sdk-reference.hbs'
setEndpointTemplateContext(file, endpoint, metadata)
setEndpointTemplateContext(file, endpoint)
}
}
}
Expand Down

0 comments on commit 2d3641d

Please sign in to comment.