created blog

main
Alex the Emperor Penguin 3 years ago
parent 72c2c5fb53
commit 91dbd1cae0

@ -0,0 +1,18 @@
import PocketBase from "pocketbase";
export const dynamic = 'auto',
fetchCache = 'force-no-store'
async function getPosts() {
const client = new PocketBase('https://backend.saachen.lu');
const adminAuthData = await client.admins.authViaEmail(process.env.USERNAME, process.env.PASSWORD);
//console.log(adminAuthData);
const resultList = await client.records.getList('blogposts', 1, 50, {
filter: 'created >= "2022-01-01 00:00:00"',
expand: 'categories'
});
//console.log(resultList);
return resultList;
}
export default getPosts();

@ -1,5 +1,8 @@
import PocketBase from "pocketbase"; import PocketBase from "pocketbase";
export const dynamic = 'force-dynamic',
fetchCache = 'force-no-store'
async function getItems() { async function getItems() {
const client = new PocketBase('https://backend.saachen.lu'); const client = new PocketBase('https://backend.saachen.lu');
const adminAuthData = await client.admins.authViaEmail(process.env.USERNAME, process.env.PASSWORD); const adminAuthData = await client.admins.authViaEmail(process.env.USERNAME, process.env.PASSWORD);
@ -7,7 +10,7 @@ async function getItems() {
const resultList = await client.records.getList('forums', 1, 50, { const resultList = await client.records.getList('forums', 1, 50, {
filter: 'created >= "2022-01-01 00:00:00"', filter: 'created >= "2022-01-01 00:00:00"',
}); });
console.log(resultList); //console.log(resultList);
return resultList; return resultList;
} }

@ -1,6 +1,38 @@
import getPosts from "./blog";
export const dynamic = 'auto',
dynamicParams = true,
revalidate = false,
fetchCache = 'force-no-cache',
runtime = 'nodejs',
preferredRegion = 'auto'
export default async function Page({ children }) { export default async function Page({ children }) {
const posts = await getPosts;
console.log(posts)
return( return(
<h1> <div>
</h1> <div>
{posts.items.map((item, i) => (
<div key={i}>
<h1>
{item.title}
</h1>
<br/>
{console.log(item["@expand"])}
{item["@expand"].categories.map((item, i) => (
<div key={i}>
{item.name}
</div>
))}
<br/>
{item.title}
<br/>
<br/>
{item.content}
</div>
))}
</div>
</div>
); );
} }

@ -3,7 +3,7 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev --turbo", "dev": "next dev",
"build": "next build", "build": "next build",
"start": "next start", "start": "next start",
"lint": "next lint" "lint": "next lint"

Loading…
Cancel
Save