Add facebook Open Graph Url and image. Fix PATH env conflict with Vercel environment

This commit is contained in:
txs
2022-04-04 08:13:18 +08:00
parent 305a476f6f
commit ebdaf4273f
33 changed files with 901 additions and 469 deletions

View File

@@ -3,23 +3,26 @@ import React from 'react'
import { useGlobal } from '@/lib/global'
import * as ThemeMap from '@/themes'
export default function Category (props) {
export default function Category(props) {
const { theme } = useGlobal()
const ThemeComponents = ThemeMap[theme]
const { siteInfo, posts } = props
const { locale } = useGlobal()
if (!posts) {
return <ThemeComponents.Layout404 {...props}/>
return <ThemeComponents.Layout404 {...props} />
}
const meta = {
title: `${props.category} | ${locale.COMMON.CATEGORY} | ${siteInfo?.title || ''}`,
title: `${props.category} | ${locale.COMMON.CATEGORY} | ${
siteInfo?.title || ''
}`,
description: siteInfo?.description,
slug: 'category/' + props.category,
type: 'website'
}
return <ThemeComponents.LayoutCategory {...props} meta={meta} />
}
export async function getStaticProps ({ params: { category } }) {
export async function getStaticProps({ params: { category } }) {
const from = 'category-props'
let props = await getGlobalNotionData({ from })
const posts = props.allPosts.filter(
@@ -33,11 +36,13 @@ export async function getStaticProps ({ params: { category } }) {
}
}
export async function getStaticPaths () {
export async function getStaticPaths() {
const from = 'category-paths'
const { categories } = await getGlobalNotionData({ from })
return {
paths: Object.keys(categories).map(category => ({ params: { category: categories[category]?.name } })),
paths: Object.keys(categories).map(category => ({
params: { category: categories[category]?.name }
})),
fallback: true
}
}

View File

@@ -3,7 +3,7 @@ import React from 'react'
import { useGlobal } from '@/lib/global'
import * as ThemeMap from '@/themes'
export default function Category (props) {
export default function Category(props) {
const { theme } = useGlobal()
const ThemeComponents = ThemeMap[theme]
const { locale } = useGlobal()
@@ -11,13 +11,17 @@ export default function Category (props) {
const meta = {
title: `${locale.COMMON.CATEGORY} | ${siteInfo.title}`,
description: siteInfo.description,
slug: 'category',
type: 'website'
}
return <ThemeComponents.LayoutCategoryIndex {...props} meta={meta}/>
return <ThemeComponents.LayoutCategoryIndex {...props} meta={meta} />
}
export async function getStaticProps () {
const props = await getGlobalNotionData({ from: 'category-index-props', categoryCount: 0 })
export async function getStaticProps() {
const props = await getGlobalNotionData({
from: 'category-index-props',
categoryCount: 0
})
return {
props,
revalidate: 1