mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-01 07:26:47 +00:00
feature: 配置文件整理
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
const BLOG = require('../blog.config')
|
||||
|
||||
module.exports = function () {
|
||||
switch (BLOG.lang.toLowerCase()) {
|
||||
switch (BLOG.LANG.toLowerCase()) {
|
||||
case 'zh-cn':
|
||||
case 'zh-sg':
|
||||
return 'SC'
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import BLOG from '@/blog.config'
|
||||
export const GA_TRACKING_ID = BLOG.analytics.gaConfig.measurementId
|
||||
|
||||
// https://developers.google.com/analytics/devguides/collection/gtagjs/pages
|
||||
export const pageview = url => {
|
||||
window.gtag('config', GA_TRACKING_ID, {
|
||||
window.gtag('config', BLOG.ANALYTICS_GOOGLE_ID, {
|
||||
page_path: url
|
||||
})
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ export async function getAllPosts ({ notionPageData, from, includePage = false }
|
||||
})
|
||||
|
||||
// Sort by date
|
||||
if (BLOG.sortByDate) {
|
||||
if (BLOG.POSTS_SORT_BY_DATE) {
|
||||
posts.sort((a, b) => {
|
||||
const dateA = new Date(a?.date?.start_date || a.createdTime)
|
||||
const dateB = new Date(b?.date?.start_date || b.createdTime)
|
||||
|
||||
@@ -13,13 +13,13 @@ import { getAllTags } from './getAllTags'
|
||||
* @param latestPostCount 截取最新文章数量
|
||||
* @param tagsCount 截取标签数量
|
||||
* @param includePage 是否包含PAGE类型
|
||||
* @returns { allPosts: '文章列表', latestPosts: ’最新文章, categories:‘分类列表’, postCount:'文章总数',tags:'标签列表' }
|
||||
* @returns {}
|
||||
* allPosts 所有博客
|
||||
* categories 所有分类
|
||||
* tags 所有标签
|
||||
*/
|
||||
export async function getGlobalNotionData ({
|
||||
pageId = BLOG.notionPageId,
|
||||
pageId = BLOG.NOTION_PAGE_ID,
|
||||
from,
|
||||
latestPostCount = 5,
|
||||
tagsCount = 16,
|
||||
|
||||
@@ -9,7 +9,7 @@ export async function getPostBlocks (id, from, slice) {
|
||||
console.log('[请求缓存]:', `from:${from}`, `id:${id}`)
|
||||
return filterPostBlocks(id, pageBlock, slice)
|
||||
}
|
||||
const authToken = BLOG.notionAccessToken || null
|
||||
const authToken = BLOG.NOTION_ACCESS_TOKEN || null
|
||||
const api = new NotionAPI({ authToken })
|
||||
try {
|
||||
console.log('[请求API]:', `from:${from}`, `id:${id}`)
|
||||
@@ -57,7 +57,7 @@ function filterPostBlocks (id, pageBlock, slice) {
|
||||
}
|
||||
|
||||
// 去掉不用的字段
|
||||
if (id === BLOG.notionPageId) {
|
||||
if (id === BLOG.NOTION_PAGE_ID) {
|
||||
return clonePageBlock
|
||||
}
|
||||
return clonePageBlock
|
||||
|
||||
30
lib/rss.js
30
lib/rss.js
@@ -4,25 +4,25 @@ import BLOG from '@/blog.config'
|
||||
export function generateRss (posts) {
|
||||
const year = new Date().getFullYear()
|
||||
const feed = new Feed({
|
||||
title: BLOG.title,
|
||||
description: BLOG.description,
|
||||
id: `${BLOG.link}/${BLOG.path}`,
|
||||
link: `${BLOG.link}/${BLOG.path}`,
|
||||
language: BLOG.lang,
|
||||
favicon: `${BLOG.link}/favicon.png`,
|
||||
copyright: `All rights reserved ${year}, ${BLOG.author}`,
|
||||
author: {
|
||||
name: BLOG.author,
|
||||
email: BLOG.email,
|
||||
link: BLOG.link
|
||||
TITLE: BLOG.TITLE,
|
||||
DESCRIPTION: BLOG.DESCRIPTION,
|
||||
id: `${BLOG.LINK}/${BLOG.PATH}`,
|
||||
LINK: `${BLOG.LINK}/${BLOG.PATH}`,
|
||||
language: BLOG.LANG,
|
||||
favicon: `${BLOG.LINK}/favicon.png`,
|
||||
copyright: `All rights reserved ${year}, ${BLOG.AUTHOR}`,
|
||||
AUTHOR: {
|
||||
name: BLOG.AUTHOR,
|
||||
email: BLOG.CONTACT_EMAIL,
|
||||
link: BLOG.LINK
|
||||
}
|
||||
})
|
||||
posts.forEach(post => {
|
||||
feed.addItem({
|
||||
title: post.title,
|
||||
id: `${BLOG.link}/article/${post.slug}`,
|
||||
link: `${BLOG.link}/article/${post.slug}`,
|
||||
description: post.summary,
|
||||
TITLE: post.title,
|
||||
id: `${BLOG.LINK}/article/${post.slug}`,
|
||||
LINK: `${BLOG.LINK}/article/${post.slug}`,
|
||||
DESCRIPTION: post.summary,
|
||||
date: new Date(post?.date?.start_date || post.createdTime)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user