整理lib目录

This commit is contained in:
tangly1024
2024-03-10 13:08:18 +08:00
parent 51743512fa
commit 444e236ca6
55 changed files with 60 additions and 64 deletions

View File

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

View File

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

View File

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

View File

@@ -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 截取最新文章数量

View File

@@ -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'
/**
* 在这里配置所有支持的语言

View File

View File

@@ -1,2 +0,0 @@
export { getAllTags } from './notion/getAllTags'
export { getPostBlocks } from './notion/getPostBlocks'

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
const { loadExternalResource } = require('./utils');
const { loadExternalResource } = require('../utils');
/**
* WOWjs动画结合animate.css使用很方便

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
import subscribeToMailchimpApi from '@/lib/mailchimp'
import subscribeToMailchimpApi from '@/lib/plugins/mailchimp'
/**
* 接受邮件订阅

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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'
/**
* 基础布局 采用上中下布局,移动端使用顶部侧边导航栏

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,7 +2,7 @@ import Link from 'next/link'
import { useGlobal } from '@/lib/global'
import CONFIG from '../config'
import { siteConfig } from '@/lib/config'
import { formatDateFmt } from '@/lib/formatDate'
import { formatDateFmt } from '@/lib/utils/formatDate'
import NotionIcon from '@/components/NotionIcon'
/**

View File

@@ -1,7 +1,7 @@
import Link from 'next/link'
import CONFIG from '../config'
import TwikooCommentCount from '@/components/TwikooCommentCount'
import { formatDateFmt } from '@/lib/formatDate'
import { formatDateFmt } from '@/lib/utils/formatDate'
import { siteConfig } from '@/lib/config'
import LazyImage from '@/components/LazyImage'
import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'

View File

@@ -36,7 +36,7 @@ import { Banner } from './components/Banner'
import { SignInForm } from './components/SignInForm'
import { SignUpForm } from './components/SignUpForm'
import Link from 'next/link'
import { loadWowJS } from '@/lib/wow'
import { loadWowJS } from '@/lib/plugins/wow'
/**
* 布局框架