Skip to content

Commit

Permalink
Structured text inline records
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanoverna committed Jan 3, 2025
1 parent 9b909f2 commit 1cc6669
Show file tree
Hide file tree
Showing 201 changed files with 34,355 additions and 19,921 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Also, make sure to use `withAllComponents`, inside `blockComponents`, `linkToRec

```jsx
<Text
data={episode.content}
{...ensureValidStructuredTextProps({ data: episode.content })}
blockComponents={withAllComponents(episode.content.blocks, {
InternalVideoRecord: InternalVideo,
ImageRecord: Image,
Expand Down
34 changes: 34 additions & 0 deletions astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import node from '@astrojs/node';
import react from '@astrojs/react';
import expressiveCode from 'astro-expressive-code';
import { defineConfig, envField } from 'astro/config';
import { writeFile } from 'fs/promises';

import bundlesize from 'vite-plugin-bundlesize';

Expand Down Expand Up @@ -99,6 +100,39 @@ export default defineConfig({
},
},
},
{
name: 'routes',
hooks: {
'astro:routes:resolved': async ({ routes }) => {
const routesWithParams = routes
.filter(
(r) =>
r.origin === 'project' &&
r.type === 'page' &&
r.params.length > 0 &&
!r.params.includes('pageIndex'),
)
.map(({ entrypoint, patternRegex, params }) => ({
entrypoint:
entrypoint
.replace('src/pages/', '../../../')
.replace('.astro', '')
.replace('/index', '') + '/_graphql.ts',
pattern: patternRegex.toString(),
params,
}));

const routesWithNoParams = routes
.filter((r) => r.origin === 'project' && r.type === 'page' && r.params.length === 0)
.map(({ pattern }) => pattern);

await writeFile(
'./src/pages/api/normalize-structured-text/_utils/routes.json',
JSON.stringify({ routesWithParams, routesWithNoParams }, null, 2),
);
},
},
},
],
// This project does not use static markdown, only remote. See our <Markdown /> component
markdown: {},
Expand Down
11 changes: 11 additions & 0 deletions datocms.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"profiles": {
"default": {
"logLevel": "NONE",
"migrations": {
"directory": "./migrations",
"modelApiKey": "schema_migration"
}
}
}
}
Loading

0 comments on commit 1cc6669

Please sign in to comment.