mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-05-05 05:46:24 -04:00
use ghost api v5 on landing
This commit is contained in:
@@ -1,53 +1,53 @@
|
||||
{
|
||||
"name": "@sd/landing",
|
||||
"scripts": {
|
||||
"dev": "pnpm run server",
|
||||
"prod": "pnpm run build && pnpm run server:prod",
|
||||
"vercel-build": "./vercel/deploy.sh",
|
||||
"build": "vite build && vite build --ssr && vite-plugin-ssr prerender",
|
||||
"server": "ts-node ./server",
|
||||
"server:prod": "cross-env NODE_ENV=production ts-node ./server"
|
||||
},
|
||||
"dependencies": {
|
||||
"@heroicons/react": "^1.0.6",
|
||||
"@icons-pack/react-simple-icons": "^5.2.0",
|
||||
"@sd/interface": "link:../../packages/interface",
|
||||
"@sd/ui": "link:../../packages/ui",
|
||||
"@tryghost/content-api": "^1.11.0",
|
||||
"@types/compression": "^1.7.2",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/node": "^17.0.31",
|
||||
"@types/react": "^18.0.8",
|
||||
"@types/react-dom": "^18.0.3",
|
||||
"@vitejs/plugin-react": "^1.3.2",
|
||||
"clsx": "^1.2.1",
|
||||
"compression": "^1.7.4",
|
||||
"cross-env": "^7.0.3",
|
||||
"express": "^4.18.1",
|
||||
"phosphor-react": "^1.4.1",
|
||||
"prismjs": "^1.28.0",
|
||||
"react": "^18.1.0",
|
||||
"react-dom": "^18.1.0",
|
||||
"react-helmet": "^6.1.0",
|
||||
"react-hook-form": "^7.33.1",
|
||||
"react-tsparticles": "^2.1.3",
|
||||
"sirv": "^2.0.2",
|
||||
"ts-node": "^10.7.0",
|
||||
"tsparticles": "^2.1.3",
|
||||
"typescript": "^4.6.4",
|
||||
"vite": "^2.9.14",
|
||||
"vite-plugin-ssr": "^0.4.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/line-clamp": "^0.4.0",
|
||||
"@tailwindcss/typography": "^0.5.4",
|
||||
"@types/prismjs": "^1.26.0",
|
||||
"@types/react-helmet": "^6.1.5",
|
||||
"@types/tryghost__content-api": "^1.3.11",
|
||||
"postcss": "^8.4.14",
|
||||
"sass": "^1.54.0",
|
||||
"tailwind": "^4.0.0",
|
||||
"vite-plugin-markdown": "^2.0.2",
|
||||
"vite-plugin-svgr": "^2.2.1"
|
||||
}
|
||||
"name": "@sd/landing",
|
||||
"scripts": {
|
||||
"dev": "pnpm run server",
|
||||
"prod": "pnpm run build && pnpm run server:prod",
|
||||
"vercel-build": "./vercel/deploy.sh",
|
||||
"build": "vite build",
|
||||
"server": "ts-node ./server",
|
||||
"server:prod": "cross-env NODE_ENV=production ts-node ./server"
|
||||
},
|
||||
"dependencies": {
|
||||
"@heroicons/react": "^1.0.6",
|
||||
"@icons-pack/react-simple-icons": "^5.2.0",
|
||||
"@sd/interface": "link:../../packages/interface",
|
||||
"@sd/ui": "link:../../packages/ui",
|
||||
"@tryghost/content-api": "^1.11.0",
|
||||
"@types/compression": "^1.7.2",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/node": "^17.0.31",
|
||||
"@types/react": "^18.0.8",
|
||||
"@types/react-dom": "^18.0.3",
|
||||
"@vitejs/plugin-react": "^1.3.2",
|
||||
"clsx": "^1.2.1",
|
||||
"compression": "^1.7.4",
|
||||
"cross-env": "^7.0.3",
|
||||
"express": "^4.18.1",
|
||||
"phosphor-react": "^1.4.1",
|
||||
"prismjs": "^1.28.0",
|
||||
"react": "^18.1.0",
|
||||
"react-dom": "^18.1.0",
|
||||
"react-helmet": "^6.1.0",
|
||||
"react-hook-form": "^7.33.1",
|
||||
"react-tsparticles": "^2.1.3",
|
||||
"sirv": "^2.0.2",
|
||||
"ts-node": "^10.7.0",
|
||||
"tsparticles": "^2.1.3",
|
||||
"typescript": "^4.6.4",
|
||||
"vite": "^2.9.14",
|
||||
"vite-plugin-ssr": "^0.4.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/line-clamp": "^0.4.0",
|
||||
"@tailwindcss/typography": "^0.5.4",
|
||||
"@types/prismjs": "^1.26.0",
|
||||
"@types/react-helmet": "^6.1.5",
|
||||
"@types/tryghost__content-api": "^1.3.11",
|
||||
"postcss": "^8.4.14",
|
||||
"sass": "^1.54.0",
|
||||
"tailwind": "^4.0.0",
|
||||
"vite-plugin-markdown": "^2.0.2",
|
||||
"vite-plugin-svgr": "^2.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,35 +7,35 @@ const ghostURL = import.meta.env.VITE_API_URL;
|
||||
export const blogEnabled = !!(ghostURL && ghostKey);
|
||||
|
||||
export const api = blogEnabled
|
||||
? new GhostContentAPI({
|
||||
url: ghostURL,
|
||||
key: ghostKey,
|
||||
version: 'v4'
|
||||
})
|
||||
: null;
|
||||
? new GhostContentAPI({
|
||||
url: ghostURL,
|
||||
key: ghostKey,
|
||||
version: 'v5.0'
|
||||
})
|
||||
: null;
|
||||
|
||||
export async function getPosts() {
|
||||
if (!api) {
|
||||
return [];
|
||||
}
|
||||
const posts = await api.posts
|
||||
.browse({
|
||||
include: ['tags', 'authors']
|
||||
})
|
||||
.catch(() => []);
|
||||
return posts;
|
||||
if (!api) {
|
||||
return [];
|
||||
}
|
||||
const posts = await api.posts
|
||||
.browse({
|
||||
include: ['tags', 'authors']
|
||||
})
|
||||
.catch(() => []);
|
||||
return posts;
|
||||
}
|
||||
|
||||
export async function getPost(slug: string) {
|
||||
if (!api) {
|
||||
return null;
|
||||
}
|
||||
return await api.posts
|
||||
.read(
|
||||
{ slug },
|
||||
{
|
||||
include: ['tags', 'authors']
|
||||
}
|
||||
)
|
||||
.catch(() => null);
|
||||
if (!api) {
|
||||
return null;
|
||||
}
|
||||
return await api.posts
|
||||
.read(
|
||||
{ slug },
|
||||
{
|
||||
include: ['tags', 'authors']
|
||||
}
|
||||
)
|
||||
.catch(() => null);
|
||||
}
|
||||
|
||||
@@ -3,22 +3,22 @@ import { PageContextBuiltIn } from 'vite-plugin-ssr';
|
||||
import { getPost, getPosts } from './api';
|
||||
|
||||
export async function onBeforeRender(pageContext: PageContextBuiltIn) {
|
||||
const post = await getPost(pageContext.routeParams['slug']);
|
||||
const post = await getPost(pageContext.routeParams['slug']);
|
||||
|
||||
return {
|
||||
pageContext: {
|
||||
pageProps: {
|
||||
post
|
||||
}
|
||||
}
|
||||
};
|
||||
return {
|
||||
pageContext: {
|
||||
pageProps: {
|
||||
post
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export async function prerender() {
|
||||
const posts = await getPosts();
|
||||
const posts = await getPosts();
|
||||
|
||||
return posts.map((post) => ({
|
||||
url: `/blog/${post.slug}`,
|
||||
pageContext: { pageProps: { post } }
|
||||
}));
|
||||
return posts.map((post) => ({
|
||||
url: `/blog/${post.slug}`,
|
||||
pageContext: { pageProps: { post } }
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user