-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
212b799
commit 2bfec33
Showing
8 changed files
with
631 additions
and
1,960 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import sitemap from '@astrojs/sitemap'; | ||
import { defineConfig, field } from 'studio-private-beta'; | ||
import db, { defineCollection, field, NOW } from '@astrojs/db'; | ||
import seed from './studio.seed.ts'; | ||
|
||
export const Blog = defineCollection({ | ||
fields: { | ||
title: field.text(), | ||
description: field.text(), | ||
slug: field.text({ optional: true }), | ||
publishedAt: field.date({ default: NOW }), | ||
updatedAt: field.date({ optional: true }), | ||
heroImage: field.text({ | ||
default: '/blog-placeholder-1.jpg', | ||
}), | ||
content: field.text({ multiline: true }), | ||
} | ||
}); | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
site: 'https://example.com', | ||
integrations: [sitemap()], | ||
studio: { | ||
integrations: [db(), sitemap()], | ||
db: { | ||
studio: true, | ||
collections: { | ||
Blog: { | ||
fields: { | ||
title: field.text(), | ||
description: field.text(), | ||
slug: field.text({ optional: true }), | ||
publishedAt: field.date({ default: 'now' }), | ||
updatedAt: field.date({ optional: true }), | ||
heroImage: field.text({ | ||
default: '/blog-placeholder-1.jpg', | ||
}), | ||
content: field.text({ multiline: true }), | ||
}, | ||
}, | ||
Blog | ||
}, | ||
data: seed | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/// <reference path="../.astro/db-types.d.ts" /> | ||
/// <reference path="../.astro/studio-types.d.ts" /> | ||
/// <reference path="../.astro/types.d.ts" /> | ||
/// <reference types="astro/client" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,45 @@ | ||
import { readFile } from 'node:fs/promises'; | ||
import { Blog, db } from 'astro:db'; | ||
import { defineData } from '@astrojs/db'; | ||
import { Blog } from './astro.config.mjs'; | ||
|
||
const lipsum = await readFile(new URL('assets/lipsum.md', import.meta.url), 'utf8'); | ||
export default defineData(async ({ seed }) => { | ||
const lipsum = await readFile(new URL('assets/lipsum.md', import.meta.url), 'utf8'); | ||
|
||
const markdownStyleGuide = await readFile( | ||
new URL('assets/markdown-style-guide.md', import.meta.url), | ||
'utf8', | ||
); | ||
const markdownStyleGuide = await readFile( | ||
new URL('assets/markdown-style-guide.md', import.meta.url), | ||
'utf8', | ||
); | ||
|
||
const posts: Array<typeof Blog.$inferInsert> = [ | ||
{ | ||
title: 'Markdown Style Guide', | ||
description: | ||
'Here is a sample of some basic Markdown syntax that can be used when writing Markdown content in Astro.', | ||
slug: 'markdown-style-guide', | ||
publishedAt: new Date('2022-07-01'), | ||
heroImage: '/blog-placeholder-1.jpg', | ||
content: markdownStyleGuide, | ||
}, | ||
{ | ||
title: 'First post', | ||
description: 'Lorem ipsum dolor sit amet', | ||
publishedAt: new Date('2022-07-08'), | ||
heroImage: '/blog-placeholder-3.jpg', | ||
content: lipsum, | ||
}, | ||
{ | ||
title: 'Second post', | ||
description: 'Lorem ipsum dolor sit amet', | ||
publishedAt: new Date('2022-07-15'), | ||
heroImage: '/blog-placeholder-4.jpg', | ||
content: lipsum, | ||
}, | ||
{ | ||
title: 'Third post', | ||
description: 'Lorem ipsum dolor sit amet', | ||
publishedAt: new Date('2022-07-22'), | ||
heroImage: '/blog-placeholder-2.jpg', | ||
content: lipsum, | ||
}, | ||
]; | ||
|
||
await db.insert(Blog).values(posts); | ||
await seed(Blog, [ | ||
{ | ||
title: 'Markdown Style Guide', | ||
description: | ||
'Here is a sample of some basic Markdown syntax that can be used when writing Markdown content in Astro.', | ||
slug: 'markdown-style-guide', | ||
publishedAt: new Date('2022-07-01'), | ||
heroImage: '/blog-placeholder-1.jpg', | ||
content: markdownStyleGuide, | ||
}, | ||
{ | ||
title: 'First post', | ||
description: 'Lorem ipsum dolor sit amet', | ||
publishedAt: new Date('2022-07-08'), | ||
heroImage: '/blog-placeholder-3.jpg', | ||
content: lipsum, | ||
}, | ||
{ | ||
title: 'Second post', | ||
description: 'Lorem ipsum dolor sit amet', | ||
publishedAt: new Date('2022-07-15'), | ||
heroImage: '/blog-placeholder-4.jpg', | ||
content: lipsum, | ||
}, | ||
{ | ||
title: 'Third post', | ||
description: 'Lorem ipsum dolor sit amet', | ||
publishedAt: new Date('2022-07-22'), | ||
heroImage: '/blog-placeholder-2.jpg', | ||
content: lipsum, | ||
}, | ||
]) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import { defineConfig } from 'studio-private-beta'; | ||
import { defineConfig } from 'astro/config'; | ||
import db from '@astrojs/db'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
studio: { | ||
integrations: [db()], | ||
db: { | ||
studio: true, | ||
collections: { | ||
// Define your studio collections here! | ||
}, | ||
// define your collections here! | ||
} | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.