feature: 配置文件整理

This commit is contained in:
tangly1024
2022-01-17 21:53:52 +08:00
parent 7c68d1aad0
commit 3f2de9e3d4
54 changed files with 284 additions and 247 deletions

View File

@@ -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'

View File

@@ -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
})
}

View File

@@ -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)

View File

@@ -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,

View File

@@ -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

View File

@@ -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)
})
})