Skip to content

Commit

Permalink
Merge pull request #2162 from tangly1024/feat/frame-work
Browse files Browse the repository at this point in the history
Feat/frame work
  • Loading branch information
tangly1024 committed Mar 10, 2024
2 parents 5174351 + 11d9eca commit de1b8fa
Show file tree
Hide file tree
Showing 58 changed files with 68 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .env.local
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables
NEXT_PUBLIC_VERSION=4.3.1
NEXT_PUBLIC_VERSION=4.3.2


# 可在此添加环境变量,去掉最左边的(# )注释即可
Expand Down
2 changes: 1 addition & 1 deletion components/Busuanzi.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import busuanzi from '@/lib/busuanzi'
import busuanzi from '@/lib/plugins/busuanzi'
import { useRouter } from 'next/router'
import { useGlobal } from '@/lib/global'
// import { useRouter } from 'next/router'
Expand Down
2 changes: 1 addition & 1 deletion components/Gtag.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect } from 'react'
import { useRouter } from 'next/router'
import * as gtag from '@/lib/gtag'
import * as gtag from '@/lib/plugins/gtag'

const Gtag = () => {
const router = useRouter()
Expand Down
2 changes: 1 addition & 1 deletion components/NotionPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Code = dynamic(() =>
const Equation = dynamic(() =>
import('@/components/Equation').then(async (m) => {
// 化学方程式
await import('@/lib/mhchem')
await import('@/lib/plugins/mhchem')
return m.Equation
}), { ssr: false }
)
Expand Down
19 changes: 11 additions & 8 deletions lib/notion/getNotionData.js → lib/db/getSiteData.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ import BLOG from '@/blog.config'
import { getDataFromCache, setDataToCache } from '@/lib/cache/cache_manager'
import { getPostBlocks, getSingleBlock } from '@/lib/notion/getPostBlocks'
import { idToUuid } from 'notion-utils'
import { deepClone } from '../utils'
import { getAllCategories } from './getAllCategories'
import getAllPageIds from './getAllPageIds'
import { getAllTags } from './getAllTags'
import getPageProperties from './getPageProperties'
import { compressImage, mapImgUrl } from './mapImage'
import { getConfigMapFromConfigPage } from './getNotionConfig'
import { deepClone } from '@/lib/utils'
import { getAllCategories } from '@/lib/notion/getAllCategories'
import getAllPageIds from '@/lib/notion/getAllPageIds'
import { getAllTags } from '@/lib/notion/getAllTags'
import getPageProperties from '@/lib/notion/getPageProperties'
import { compressImage, mapImgUrl } from '@/lib/notion/mapImage'
import { getConfigMapFromConfigPage } from '@/lib/notion/getNotionConfig'

export { getAllTags } from '../notion/getAllTags'
export { getPostBlocks } from '../notion/getPostBlocks'

/**
* 获取博客数据
* 获取博客数据; 基于Notion实现
* @param {*} pageId
* @param {*} from
* @param latestPostCount 截取最新文章数量
Expand Down
2 changes: 1 addition & 1 deletion lib/lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import zhTW from './lang/zh-TW'
import frFR from './lang/fr-FR'
import trTR from './lang/tr-TR'
import jaJP from './lang/ja-JP'
import { getQueryVariable, isBrowser, mergeDeep } from './utils'
import { getQueryVariable, isBrowser, mergeDeep } from '@/lib/utils'

/**
* 在这里配置所有支持的语言
Expand Down
Empty file removed lib/memorize.js
Empty file.
2 changes: 0 additions & 2 deletions lib/notion.js

This file was deleted.

2 changes: 1 addition & 1 deletion lib/notion/getAllPosts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import BLOG from '@/blog.config'
import getAllPageIds from './getAllPageIds'
import getPageProperties from './getPageProperties'
import { getNotionPageData } from '@/lib/notion/getNotionData'
import { getNotionPageData } from '@/lib/db/getSiteData'
import { delCacheData } from '@/lib/cache/cache_manager'

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/notion/getNotion.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BLOG from '@/blog.config'
import { idToUuid } from 'notion-utils'
import formatDate from '../formatDate'
import formatDate from '../utils/formatDate'
import { getPostBlocks } from './getPostBlocks'
import { defaultMapImageUrl } from 'react-notion-x'

Expand Down
2 changes: 1 addition & 1 deletion lib/notion/getPageProperties.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getTextContent, getDateValue } from 'notion-utils'
import { NotionAPI } from 'notion-client'
import BLOG from '@/blog.config'
import formatDate from '../formatDate'
import formatDate from '../utils/formatDate'
// import { createHash } from 'crypto'
import md5 from 'js-md5'
import { mapImgUrl } from './mapImage'
Expand Down
6 changes: 6 additions & 0 deletions lib/notion/getPostBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export async function getPostBlocks(id, from, slice) {
return pageBlock
}

/**
* 针对在getDataBaseInfoByNotionAPI=>getPostBlocks中获取不到的溢出的block-id,用此方法另外抓取
* @param {*} id
* @param {*} from
* @returns
*/
export async function getSingleBlock(id, from) {
const cacheKey = 'single_block_' + id
let pageBlock = await getDataFromCache(cacheKey)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/wow.js → lib/plugins/wow.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { loadExternalResource } = require('./utils');
const { loadExternalResource } = require('../utils');

/**
* WOWjs动画,结合animate.css使用很方便
Expand Down
2 changes: 1 addition & 1 deletion lib/rss.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'fs'
import { Feed } from 'feed'
import BLOG from '@/blog.config'
import ReactDOMServer from 'react-dom/server'
import { getPostBlocks } from './notion'
import { getPostBlocks } from '@/lib/db/getSiteData'
import NotionPage from '@/components/NotionPage'

/**
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "notion-next",
"version": "4.3.1",
"version": "4.3.2",
"homepage": "https://github.com/tangly1024/NotionNext.git",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion pages/404.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData } from '@/lib/db/getSiteData'
import { useRouter } from 'next/router'
import { getLayoutByTheme } from '@/themes/theme'
import { siteConfig } from '@/lib/config'
Expand Down
5 changes: 2 additions & 3 deletions pages/[prefix]/[slug]/[...suffix].js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import BLOG from '@/blog.config'
import { getPostBlocks } from '@/lib/notion'
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData, getPostBlocks } from '@/lib/db/getSiteData'
import { idToUuid } from 'notion-utils'
import { getNotion } from '@/lib/notion/getNotion'
import Slug, { getRecommendPost } from '..'
import { uploadDataToAlgolia } from '@/lib/algolia'
import { uploadDataToAlgolia } from '@/lib/plugins/algolia'
import { checkContainHttp } from '@/lib/utils'

/**
Expand Down
5 changes: 2 additions & 3 deletions pages/[prefix]/[slug]/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import BLOG from '@/blog.config'
import { getPostBlocks } from '@/lib/notion'
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData, getPostBlocks } from '@/lib/db/getSiteData'
import { idToUuid } from 'notion-utils'
import { getNotion } from '@/lib/notion/getNotion'
import Slug, { getRecommendPost } from '..'
import { uploadDataToAlgolia } from '@/lib/algolia'
import { uploadDataToAlgolia } from '@/lib/plugins/algolia'
import { checkContainHttp } from '@/lib/utils'

/**
Expand Down
5 changes: 2 additions & 3 deletions pages/[prefix]/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import BLOG from '@/blog.config'
import { getPostBlocks } from '@/lib/notion'
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData, getPostBlocks } from '@/lib/db/getSiteData'
import { useEffect, useState } from 'react'
import { idToUuid } from 'notion-utils'
import { useRouter } from 'next/router'
Expand All @@ -9,7 +8,7 @@ import { getPageTableOfContents } from '@/lib/notion/getPageTableOfContents'
import { getLayoutByTheme } from '@/themes/theme'
import md5 from 'js-md5'
import { checkContainHttp } from '@/lib/utils'
import { uploadDataToAlgolia } from '@/lib/algolia'
import { uploadDataToAlgolia } from '@/lib/plugins/algolia'
import { siteConfig } from '@/lib/config'

/**
Expand Down
2 changes: 1 addition & 1 deletion pages/api/subscribe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import subscribeToMailchimpApi from '@/lib/mailchimp'
import subscribeToMailchimpApi from '@/lib/plugins/mailchimp'

/**
* 接受邮件订阅
Expand Down
4 changes: 2 additions & 2 deletions pages/archive/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData } from '@/lib/db/getSiteData'
import { useEffect } from 'react'
import BLOG from '@/blog.config'
import { useRouter } from 'next/router'
import { getLayoutByTheme } from '@/themes/theme'
import { isBrowser } from '@/lib/utils'
import { formatDateFmt } from '@/lib/formatDate'
import { formatDateFmt } from '@/lib/utils/formatDate'
import { siteConfig } from '@/lib/config'

const ArchiveIndex = props => {
Expand Down
2 changes: 1 addition & 1 deletion pages/category/[category]/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData } from '@/lib/db/getSiteData'
import React from 'react'
import BLOG from '@/blog.config'
import { useRouter } from 'next/router'
Expand Down
2 changes: 1 addition & 1 deletion pages/category/[category]/page/[page].js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData } from '@/lib/db/getSiteData'
import React from 'react'
import BLOG from '@/blog.config'
import { useRouter } from 'next/router'
Expand Down
2 changes: 1 addition & 1 deletion pages/category/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData } from '@/lib/db/getSiteData'
import React from 'react'
import BLOG from '@/blog.config'
import { useRouter } from 'next/router'
Expand Down
3 changes: 1 addition & 2 deletions pages/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import BLOG from '@/blog.config'
import { getPostBlocks } from '@/lib/notion'
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData, getPostBlocks } from '@/lib/db/getSiteData'
import { generateRss } from '@/lib/rss'
import { generateRobotsTxt } from '@/lib/robots.txt'
import { getLayoutByTheme } from '@/themes/theme'
Expand Down
3 changes: 1 addition & 2 deletions pages/page/[page].js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import BLOG from '@/blog.config'
import { getPostBlocks } from '@/lib/notion'
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData, getPostBlocks } from '@/lib/db/getSiteData'
import { useRouter } from 'next/router'
import { getLayoutByTheme } from '@/themes/theme'
import { siteConfig } from '@/lib/config'
Expand Down
2 changes: 1 addition & 1 deletion pages/search/[keyword]/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData } from '@/lib/db/getSiteData'
import { getDataFromCache } from '@/lib/cache/cache_manager'
import BLOG from '@/blog.config'
import { useRouter } from 'next/router'
Expand Down
2 changes: 1 addition & 1 deletion pages/search/[keyword]/page/[page].js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData } from '@/lib/db/getSiteData'
import { getDataFromCache } from '@/lib/cache/cache_manager'
import BLOG from '@/blog.config'
import { useRouter } from 'next/router'
Expand Down
2 changes: 1 addition & 1 deletion pages/search/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData } from '@/lib/db/getSiteData'
import { useRouter } from 'next/router'
import BLOG from '@/blog.config'
import { getLayoutByTheme } from '@/themes/theme'
Expand Down
2 changes: 1 addition & 1 deletion pages/signin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BLOG from '@/blog.config'
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData } from '@/lib/db/getSiteData'
import { useRouter } from 'next/router'
import { getLayoutByTheme } from '@/themes/theme'
import { siteConfig } from '@/lib/config'
Expand Down
2 changes: 1 addition & 1 deletion pages/signup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BLOG from '@/blog.config'
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData } from '@/lib/db/getSiteData'
import { useRouter } from 'next/router'
import { getLayoutByTheme } from '@/themes/theme'
import { siteConfig } from '@/lib/config'
Expand Down
2 changes: 1 addition & 1 deletion pages/sitemap.xml.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// pages/sitemap.xml.js
import { getServerSideSitemap } from 'next-sitemap'
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData } from '@/lib/db/getSiteData'
import BLOG from '@/blog.config'

export const getServerSideProps = async (ctx) => {
Expand Down
2 changes: 1 addition & 1 deletion pages/tag/[tag]/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData } from '@/lib/db/getSiteData'
import BLOG from '@/blog.config'
import { useRouter } from 'next/router'
import { getLayoutByTheme } from '@/themes/theme'
Expand Down
2 changes: 1 addition & 1 deletion pages/tag/[tag]/page/[page].js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData } from '@/lib/db/getSiteData'
import BLOG from '@/blog.config'
import { useRouter } from 'next/router'
import { getLayoutByTheme } from '@/themes/theme'
Expand Down
2 changes: 1 addition & 1 deletion pages/tag/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getGlobalData } from '@/lib/notion/getNotionData'
import { getGlobalData } from '@/lib/db/getSiteData'
import BLOG from '@/blog.config'
import { useRouter } from 'next/router'
import { getLayoutByTheme } from '@/themes/theme'
Expand Down
2 changes: 1 addition & 1 deletion themes/example/components/ArticleInfo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Link from 'next/link'
import { useGlobal } from '@/lib/global'
import { formatDateFmt } from '@/lib/formatDate'
import { formatDateFmt } from '@/lib/utils/formatDate'

export const ArticleInfo = (props) => {
const { post } = props
Expand Down
2 changes: 1 addition & 1 deletion themes/fukasawa/components/ArticleDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Link from 'next/link'
import ArticleAround from './ArticleAround'
import { AdSlot } from '@/components/GoogleAdsense'
import LazyImage from '@/components/LazyImage'
import { formatDateFmt } from '@/lib/formatDate'
import { formatDateFmt } from '@/lib/utils/formatDate'
import WWAds from '@/components/WWAds'
import NotionIcon from '@/components/NotionIcon'

Expand Down
2 changes: 1 addition & 1 deletion themes/fukasawa/components/MailChimpForm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useRef, useState } from 'react'
import { subscribeToNewsletter } from '@/lib/mailchimp'
import { subscribeToNewsletter } from '@/lib/plugins/mailchimp'
import { siteConfig } from '@/lib/config'
import CONFIG from '../config'
import { useGlobal } from '@/lib/global'
Expand Down
2 changes: 1 addition & 1 deletion themes/heo/components/PostHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import WavesArea from './WavesArea'
import { HashTag } from '@/components/HeroIcons'
import WordCount from '@/components/WordCount'
import LazyImage from '@/components/LazyImage'
import { formatDateFmt } from '@/lib/formatDate'
import { formatDateFmt } from '@/lib/utils/formatDate'

export default function PostHeader({ post, siteInfo }) {
if (!post) {
Expand Down
2 changes: 1 addition & 1 deletion themes/heo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import WWAds from '@/components/WWAds'
import { AdSlot } from '@/components/GoogleAdsense'
import { siteConfig } from '@/lib/config'
import { isBrowser } from '@/lib/utils'
import { loadWowJS } from '@/lib/wow'
import { loadWowJS } from '@/lib/plugins/wow'

/**
* 基础布局 采用上中下布局,移动端使用顶部侧边导航栏
Expand Down
2 changes: 1 addition & 1 deletion themes/hexo/components/BlogPostCardInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Link from 'next/link'
import TagItemMini from './TagItemMini'
import TwikooCommentCount from '@/components/TwikooCommentCount'
import { siteConfig } from '@/lib/config'
import { formatDateFmt } from '@/lib/formatDate'
import { formatDateFmt } from '@/lib/utils/formatDate'
import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
import NotionIcon from '@/components/NotionIcon'

Expand Down
2 changes: 1 addition & 1 deletion themes/hexo/components/PostHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import TagItemMini from './TagItemMini'
import { useGlobal } from '@/lib/global'
import NotionIcon from '@/components/NotionIcon'
import LazyImage from '@/components/LazyImage'
import { formatDateFmt } from '@/lib/formatDate'
import { formatDateFmt } from '@/lib/utils/formatDate'
import { siteConfig } from '@/lib/config'

export default function PostHeader({ post, siteInfo }) {
Expand Down
2 changes: 1 addition & 1 deletion themes/landing/components/Footer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { subscribeToNewsletter } from '@/lib/mailchimp'
import { subscribeToNewsletter } from '@/lib/plugins/mailchimp'
import Link from 'next/link'
import { useEffect, useRef, useState } from 'react'
import CONFIG from '../config'
Expand Down
2 changes: 1 addition & 1 deletion themes/landing/components/Newsletter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { subscribeToNewsletter } from '@/lib/mailchimp'
import { subscribeToNewsletter } from '@/lib/plugins/mailchimp'
import { useEffect, useRef, useState } from 'react'
import CONFIG from '../config'
import { siteConfig } from '@/lib/config'
Expand Down
2 changes: 1 addition & 1 deletion themes/matery/components/ArticleInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Link from 'next/link'
import { useGlobal } from '@/lib/global'
import TagItemMiddle from './TagItemMiddle'
import WordCount from './WordCount'
import { formatDateFmt } from '@/lib/formatDate'
import { formatDateFmt } from '@/lib/utils/formatDate'

export const ArticleInfo = (props) => {
const { post } = props
Expand Down
2 changes: 1 addition & 1 deletion themes/matery/components/BlogPostCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TagItemMini from './TagItemMini'
import CONFIG from '../config'
import TwikooCommentCount from '@/components/TwikooCommentCount'
import LazyImage from '@/components/LazyImage'
import { formatDateFmt } from '@/lib/formatDate'
import { formatDateFmt } from '@/lib/utils/formatDate'
import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
import NotionIcon from '@/components/NotionIcon'

Expand Down
2 changes: 1 addition & 1 deletion themes/next/components/ArticleDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import NotionPage from '@/components/NotionPage'
import CONFIG from '../config'
import NotionIcon from '@/components/NotionIcon'
import LazyImage from '@/components/LazyImage'
import { formatDateFmt } from '@/lib/formatDate'
import { formatDateFmt } from '@/lib/utils/formatDate'
import { siteConfig } from '@/lib/config'
import WWAds from '@/components/WWAds'

Expand Down
2 changes: 1 addition & 1 deletion themes/next/components/BlogPostCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import CONFIG from '../config'
import NotionPage from '@/components/NotionPage'
import NotionIcon from '@/components/NotionIcon'
import TwikooCommentCount from '@/components/TwikooCommentCount'
import { formatDateFmt } from '@/lib/formatDate'
import { formatDateFmt } from '@/lib/utils/formatDate'
import { siteConfig } from '@/lib/config'
import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'

Expand Down
Loading

0 comments on commit de1b8fa

Please sign in to comment.