Skip to content

Commit 12dc017

Browse files
committed
Initial commit
0 parents  commit 12dc017

27 files changed

+12132
-0
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
end_of_line = lf
10+
max_line_length = null

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "npm" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Payload Dashboard Analytics Plugin (ALPHA)
2+
3+
**Expect breaking changes.**
4+
5+
A plugin for [Payload CMS](https://github.com/payloadcms/payload) to connect analytics data to your Payload dashboard.
6+
7+
Roadmap to stable release:
8+
9+
- Support for GA
10+
- Support for Plausible
11+
12+
## Installation
13+
14+
```bash
15+
yarn add @nouance/payload-dashboard-analytics
16+
# OR
17+
npm i @nouance/payload-dashboard-analytics
18+
```
19+
20+
## Basic Usage
21+
22+
In the `plugins` array of your [Payload config](https://payloadcms.com/docs/configuration/overview), call the plugin with [options](#options):
23+
24+
```ts
25+
// add example
26+
```
27+
28+
## Development
29+
30+
For development purposes, there is a full working example of how this plugin might be used in the [demo](./demo) of this repo. Then:
31+
32+
```bash
33+
git clone [email protected]:NouanceLabs/payload-dashboard-analytics.git \
34+
cd payload-dashboard-analytics && yarn \
35+
cd demo && yarn \
36+
cp .env.example .env \
37+
vim .env \ # add your API creds to this file
38+
yarn dev
39+
```

demo/.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
MONGODB_URI=
2+
PAYLOAD_SECRET=
3+
4+
PLAUSIBLE_API_KEY=

demo/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
media
3+
4+
.env

demo/nodemon.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"ext": "ts",
3+
"exec": "ts-node src/server.ts"
4+
}

demo/package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "payload-dashboard-analytics",
3+
"description": "Payload project created from blog template",
4+
"version": "1.0.0",
5+
"main": "dist/server.js",
6+
"license": "MIT",
7+
"scripts": {
8+
"dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon",
9+
"build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload build",
10+
"build:server": "tsc",
11+
"build": "yarn copyfiles && yarn build:payload && yarn build:server",
12+
"serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js NODE_ENV=production node dist/server.js",
13+
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png}\" dist/",
14+
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:types",
15+
"generate:graphQLSchema": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:graphQLSchema"
16+
},
17+
"dependencies": {
18+
"dotenv": "^8.2.0",
19+
"express": "^4.17.1",
20+
"payload": "^1.6.15"
21+
},
22+
"devDependencies": {
23+
"@types/express": "^4.17.9",
24+
"copyfiles": "^2.4.1",
25+
"cross-env": "^7.0.3",
26+
"nodemon": "^2.0.6",
27+
"ts-node": "^9.1.1",
28+
"typescript": "^4.8.4"
29+
}
30+
}

demo/src/collections/Categories.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { CollectionConfig } from 'payload/types';
2+
3+
const Categories: CollectionConfig = {
4+
slug: 'categories',
5+
admin: {
6+
useAsTitle: 'name',
7+
},
8+
access: {
9+
read: () => true,
10+
},
11+
fields: [
12+
{
13+
name: 'name',
14+
type: 'text',
15+
},
16+
],
17+
timestamps: false,
18+
}
19+
20+
export default Categories;

demo/src/collections/Media.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import path from 'path';
2+
import type { CollectionConfig } from 'payload/types';
3+
4+
const Media: CollectionConfig = {
5+
slug: 'media',
6+
upload: {
7+
staticDir: path.resolve(__dirname, '../../media'),
8+
// Specify the size name that you'd like to use as admin thumbnail
9+
adminThumbnail: 'thumbnail',
10+
imageSizes: [
11+
{
12+
height: 400,
13+
width: 400,
14+
crop: 'center',
15+
name: 'thumbnail',
16+
},
17+
{
18+
width: 900,
19+
height: 450,
20+
crop: 'center',
21+
name: 'sixteenByNineMedium',
22+
},
23+
],
24+
},
25+
fields: [],
26+
};
27+
28+
export default Media;

0 commit comments

Comments
 (0)