generated from autonomic-cooperative/astro-payload-template
Compare commits
3 Commits
09ad9bdc6d
...
2a494425ad
Author | SHA1 | Date | |
---|---|---|---|
2a494425ad | |||
b91dd893a4 | |||
691729c53c |
27
astro/src/components/Author.astro
Normal file
27
astro/src/components/Author.astro
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
import { Image } from "@astrojs/image/components";
|
||||||
|
import type { Author } from "@/types/payload-types";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
author: Author;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { author } = Astro.props;
|
||||||
|
---
|
||||||
|
{ (author) &&
|
||||||
|
<div class="flex gap-6 border-t-2 border-secondary py-4 text-secondary">
|
||||||
|
{(typeof author.avatar === 'object') &&
|
||||||
|
<Image
|
||||||
|
src={author.avatar.url || ""}
|
||||||
|
width={150}
|
||||||
|
height={150}
|
||||||
|
aspectRatio={1}
|
||||||
|
alt={author.avatar.alt || ""}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<h3 class="font-semibold text-base">{author.name}</h3>
|
||||||
|
<p class="text-sm font-light">{author.bio}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
@ -1,8 +1,9 @@
|
|||||||
---
|
---
|
||||||
import ContentLayout from "@/layouts/ContentLayout.astro";
|
import ContentLayout from "@/layouts/ContentLayout.astro";
|
||||||
import Content from "@/components/Content.astro";
|
import Content from "@/components/Content.astro";
|
||||||
import type { Post } from "@/types";
|
import type { Post } from "@/types/payload-types";
|
||||||
import { getPost, getPosts } from "@/utils/payload";
|
import { getPost, getPosts } from "@/utils/payload";
|
||||||
|
import Author from "@/components/Author.astro";
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const posts = await getPosts();
|
const posts = await getPosts();
|
||||||
@ -18,11 +19,15 @@ const post = id && (await getPost(id));
|
|||||||
|
|
||||||
{
|
{
|
||||||
post ? (
|
post ? (
|
||||||
<ContentLayout title={`Paystro | ${post.title!}`}>
|
<ContentLayout title={`${post.title!}`}>
|
||||||
<article class="space-y-3 my-3 max-w-prose">
|
<article class="space-y-3 my-3 max-w-prose">
|
||||||
<h1 class="">{post.title}</h1>
|
<h1 class="">{post.title}</h1>
|
||||||
{post.content && <Content content={post.content} />}
|
{post.content && <Content content={post.content} />}
|
||||||
</article>
|
</article>
|
||||||
|
{typeof post.author === 'object' &&
|
||||||
|
<aside class="mt-8">
|
||||||
|
<Author author={post.author} />
|
||||||
|
</aside>}
|
||||||
</ContentLayout>
|
</ContentLayout>
|
||||||
) : (
|
) : (
|
||||||
<div>404</div>
|
<div>404</div>
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"version": "1.2",
|
"version": "1.2",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "docker compose up --build",
|
"dev": "yarn dev:docker & yarn payload:types",
|
||||||
|
"dev:docker": "docker compose up --build",
|
||||||
|
"payload:types": "yarn --cwd ./payload run generate:types:listen",
|
||||||
"stop": "docker compose down",
|
"stop": "docker compose down",
|
||||||
"dev:nobuild": "docker compose up"
|
"dev:nobuild": "docker compose up"
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
"build:server": "tsc",
|
"build:server": "tsc",
|
||||||
"build": "yarn build:payload && yarn build:server",
|
"build": "yarn build:payload && yarn build:server",
|
||||||
"serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js node -r tsconfig-paths/register dist/server.js",
|
"serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js node -r tsconfig-paths/register dist/server.js",
|
||||||
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts node -r tsconfig-paths/register node_modules/payload/dist/bin/index.js generate:types"
|
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts node -r tsconfig-paths/register node_modules/payload/dist/bin/index.js generate:types",
|
||||||
|
"generate:types:listen": "nodemon --watch src --ext ts --exec 'npm run generate:types'"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
|
@ -3,12 +3,11 @@ import { isAdmin } from "@/access/isAdmin";
|
|||||||
import { isEditor } from "@/access/isEditor";
|
import { isEditor } from "@/access/isEditor";
|
||||||
import { isSSG } from "@/access/isSSG";
|
import { isSSG } from "@/access/isSSG";
|
||||||
import { isUser } from "@/access/isUser";
|
import { isUser } from "@/access/isUser";
|
||||||
import { isEditorOrSelf } from "@/access/isEditorOrSelf";
|
|
||||||
|
|
||||||
const Authors: CollectionConfig = {
|
const Authors: CollectionConfig = {
|
||||||
slug: "authors",
|
slug: "authors",
|
||||||
admin: {
|
admin: {
|
||||||
defaultColumns: ["avatar","name"],
|
defaultColumns: ["name"],
|
||||||
useAsTitle: "name",
|
useAsTitle: "name",
|
||||||
},
|
},
|
||||||
access: {
|
access: {
|
||||||
@ -19,20 +18,26 @@ const Authors: CollectionConfig = {
|
|||||||
delete: isEditor,
|
delete: isEditor,
|
||||||
},
|
},
|
||||||
fields: [
|
fields: [
|
||||||
|
{
|
||||||
|
name: "avatar",
|
||||||
|
type: "upload",
|
||||||
|
relationTo: "media",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
type: "text",
|
type: "text",
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "avatar",
|
name: "bio",
|
||||||
type: "upload",
|
type: "text",
|
||||||
relationTo: "media",
|
|
||||||
required: false,
|
required: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: "user",
|
name: "user",
|
||||||
type: "relationship",
|
type: "upload",
|
||||||
relationTo: "users",
|
relationTo: "users",
|
||||||
admin: {
|
admin: {
|
||||||
description: 'The selected user will be able to edit this author'
|
description: 'The selected user will be able to edit this author'
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { isUser } from "@/access/isUser";
|
||||||
import { CollectionConfig } from "payload/types";
|
import { CollectionConfig } from "payload/types";
|
||||||
|
|
||||||
export const Media: CollectionConfig = {
|
export const Media: CollectionConfig = {
|
||||||
@ -5,15 +6,15 @@ export const Media: CollectionConfig = {
|
|||||||
admin: {},
|
admin: {},
|
||||||
access: {
|
access: {
|
||||||
read: (): boolean => true,
|
read: (): boolean => true,
|
||||||
create: () => true,
|
create: isUser,
|
||||||
update: () => true,
|
update: isUser,
|
||||||
|
delete: isUser,
|
||||||
},
|
},
|
||||||
upload: {
|
upload: {
|
||||||
staticURL: "/media",
|
staticURL: "/media",
|
||||||
staticDir: "media",
|
staticDir: "media",
|
||||||
mimeTypes: ["image/*"],
|
mimeTypes: ["image/*"],
|
||||||
},
|
},
|
||||||
|
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "alt",
|
name: "alt",
|
||||||
|
@ -6,6 +6,7 @@ const Users: CollectionConfig = {
|
|||||||
slug: 'users',
|
slug: 'users',
|
||||||
auth: true,
|
auth: true,
|
||||||
admin: {
|
admin: {
|
||||||
|
defaultColumns: ["roles", "email"],
|
||||||
useAsTitle: 'email',
|
useAsTitle: 'email',
|
||||||
},
|
},
|
||||||
access: {
|
access: {
|
||||||
@ -22,7 +23,7 @@ const Users: CollectionConfig = {
|
|||||||
{ label: 'ssg', value: 'ssg' }, //cRud
|
{ label: 'ssg', value: 'ssg' }, //cRud
|
||||||
{ label: 'Admin', value: 'admin' }, //CRUD, role creation
|
{ label: 'Admin', value: 'admin' }, //CRUD, role creation
|
||||||
{ label: 'Editor', value: 'editor' }, //CRUD
|
{ label: 'Editor', value: 'editor' }, //CRUD
|
||||||
{ label: 'User', value: 'user' }, //CRUd
|
{ label: 'User', value: 'user' }, //cRud, CRUD own entries
|
||||||
],
|
],
|
||||||
required: true,
|
required: true,
|
||||||
defaultValue: "user",
|
defaultValue: "user",
|
||||||
|
Reference in New Issue
Block a user