Skip to content

Commit

Permalink
update templates
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Feb 13, 2024
1 parent 212b799 commit 2bfec33
Show file tree
Hide file tree
Showing 8 changed files with 631 additions and 1,960 deletions.
2,420 changes: 551 additions & 1,869 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

38 changes: 22 additions & 16 deletions templates/studio-template-blog/astro.config.mjs
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
},
});
12 changes: 6 additions & 6 deletions templates/studio-template-blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/rss": "^4.0.1",
"@astrojs/sitemap": "^3.0.3",
"astro": "^4.0.4",
"@astrojs/db": "^0.3.1",
"@astrojs/rss": "^4.0.5",
"@astrojs/sitemap": "^3.0.5",
"astro": "^4.3.6",
"drizzle-orm": "^0.29.1",
"marked": "^11.0.1",
"studio-private-beta": "npm:leaf-simplest-round-ride@^0.1.3"
"marked": "^11.0.1"
},
"devDependencies": {
"@astrojs/check": "^0.3.2",
"@astrojs/check": "^0.5.3",
"@types/node": "^20.10.4",
"typescript": "^5.3.3"
}
Expand Down
1 change: 1 addition & 0 deletions templates/studio-template-blog/src/env.d.ts
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" />
81 changes: 41 additions & 40 deletions templates/studio-template-blog/studio.seed.ts
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,
},
])
})
11 changes: 7 additions & 4 deletions templates/studio-template-empty/astro.config.mjs
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!
}
},
});
6 changes: 3 additions & 3 deletions templates/studio-template-empty/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.0.4",
"studio-private-beta": "npm:leaf-simplest-round-ride@^0.1.3"
"@astrojs/db": "^0.3.1",
"astro": "^4.3.6"
},
"devDependencies": {
"@astrojs/check": "^0.3.2",
"@astrojs/check": "^0.5.3",
"typescript": "^5.3.3"
}
}
22 changes: 0 additions & 22 deletions templates/studio-template-empty/studio.seed.ts

This file was deleted.

0 comments on commit 2bfec33

Please sign in to comment.