diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bdb82ccd4..2f59f1cbd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,7 +16,17 @@ jobs: - name: Setup bun uses: oven-sh/setup-bun@v1 - name: Install dependencies - run: bun install + run: bun install --frozen-lockfile + - name: Cache Next.js build + uses: actions/cache@v3 + with: + path: | + ${{ github.workspace }}/.next/cache + # Generate a new cache whenever packages or source files change. + key: ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} + # If source files changed but packages didn't, rebuild from a prior cache. + restore-keys: | + ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}- - name: Build Next.js with next-on-pages run: bun run build:cloudflare - id: cloudflare @@ -45,7 +55,7 @@ jobs: - name: Setup bun uses: oven-sh/setup-bun@v1 - name: Install dependencies - run: bun install + run: bun install --frozen-lockfile - name: Run visual tests run: bun ./tests/visual-testing.ts $DEPLOYMENT_URL env: @@ -64,9 +74,42 @@ jobs: - name: Setup bun uses: oven-sh/setup-bun@v1 - name: Install dependencies - run: bun install + run: bun install --frozen-lockfile - name: Run visual tests run: bun ./tests/pagespeed-testing.ts $DEPLOYMENT_URL env: DEPLOYMENT_URL: ${{needs.deploy.outputs.deployment_url}} PAGESPEED_API_KEY: ${{ secrets.PAGESPEED_API_KEY }} + format: + runs-on: ubuntu-latest + name: Format + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup bun + uses: oven-sh/setup-bun@v1 + - name: Install dependencies + run: bun install --frozen-lockfile + - run: bun format --check . + lint: + runs-on: ubuntu-latest + name: Lint + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup bun + uses: oven-sh/setup-bun@v1 + - name: Install dependencies + run: bun install --frozen-lockfile + - run: bun lint + typecheck: + runs-on: ubuntu-latest + name: Typecheck + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup bun + uses: oven-sh/setup-bun@v1 + - name: Install dependencies + run: bun install --frozen-lockfile + - run: bun typecheck diff --git a/src/components/DocumentView/Swagger/Swagger.tsx b/src/components/DocumentView/Swagger/Swagger.tsx index 06d2fc3c8..4beb25105 100644 --- a/src/components/DocumentView/Swagger/Swagger.tsx +++ b/src/components/DocumentView/Swagger/Swagger.tsx @@ -23,7 +23,9 @@ export async function Swagger(props: BlockProps) { // ? api.paths?.[block.data.path]?.[block.data.method] // : null; - const operation = {}; + const operation = { + summary: '', + }; return (
) { 'font-mono text-[0.625rem] font-semibold leading-6 rounded-lg px-1.5 ring-1 ring-inset ring-emerald-300 dark:ring-emerald-400/30 bg-emerald-400/10 text-emerald-500 dark:text-emerald-400', )} > - {block.data.method.toUpperCase()} + {block.data.method?.toUpperCase()} & { @@ -15,7 +16,7 @@ export async function RecordCard( const { view, record, context, isOffscreen } = props; const coverFile = view.coverDefinition - ? (record[1].values[view.coverDefinition]?.[0] as string) + ? getRecordValue(record[1], view.coverDefinition)?.[0] : null; const cover = coverFile ? await resolveContentRef({ kind: 'file', file: coverFile }, context) diff --git a/src/components/DocumentView/Table/utils.ts b/src/components/DocumentView/Table/utils.ts new file mode 100644 index 000000000..137b26074 --- /dev/null +++ b/src/components/DocumentView/Table/utils.ts @@ -0,0 +1,12 @@ +import { ContentRef, DocumentTableRecord } from '@gitbook/api'; + +/** + * Get the value for a column in a record. + */ +export function getRecordValue( + record: DocumentTableRecord, + definitionId: string, +): T { + // @ts-ignore + return record.values[definitionId]; +} diff --git a/src/lib/links.ts b/src/lib/links.ts index e71ef080c..60d8f533c 100644 --- a/src/lib/links.ts +++ b/src/lib/links.ts @@ -1,6 +1,11 @@ import 'server-only'; -import { RevisionPage, RevisionPageDocument, RevisionPageGroup } from '@gitbook/api'; +import { + RevisionPage, + RevisionPageDocument, + RevisionPageGroup, + RevisionPageType, +} from '@gitbook/api'; import { headers } from 'next/headers'; import { getPagePath } from './pages'; @@ -96,9 +101,12 @@ export function pageHref( if (pdf.includes(page.id)) { return '#' + pagePDFContainerId(page, anchor); } else { + if (page.type === RevisionPageType.Group) { + return '#'; + } + // Use an absolute URL to the page - // TODO: we need to extend RevisionPageDocument with "urls" - return page.urls?.published || '/todo'; + return page.urls.app; } } diff --git a/types/images.d.ts b/types/images.d.ts new file mode 100644 index 000000000..59e75546e --- /dev/null +++ b/types/images.d.ts @@ -0,0 +1,26 @@ +declare module '*.svg' { + const value: { + src: string; + width: number; + height: number; + }; + export default value; +} + +declare module '*.png' { + const value: { + src: string; + width: number; + height: number; + }; + export default value; +} + +declare module '*.jpg' { + const value: { + src: string; + width: number; + height: number; + }; + export default value; +}