Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jan 10, 2024
2 parents 0b9a2f7 + 0acf2d7 commit 2a06e52
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 11 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.1.3
NEXT_PUBLIC_VERSION=4.1.4


# 可在此添加环境变量,去掉最左边的(# )注释即可
Expand Down
3 changes: 2 additions & 1 deletion lib/global.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateLocaleDict, initLocale } from './lang'
import { generateLocaleDict, initLocale, saveLangToCookies } from './lang'
import { createContext, useContext, useEffect, useState } from 'react'
import { useRouter } from 'next/router'
import { THEMES, initDarkMode, saveDarkModeToCookies } from '@/themes/theme'
Expand Down Expand Up @@ -49,6 +49,7 @@ export function GlobalContextProvider(props) {
*/
function changeLang(lang) {
if (lang) {
saveLangToCookies(lang)
updateLang(lang)
updateLocale(generateLocaleDict(lang))
}
Expand Down
6 changes: 3 additions & 3 deletions lib/lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ export const loadLangFromCookies = () => {
}

/**
* 保存语言
* @param newTheme
*/
* 保存语言
* @param newTheme
*/
export const saveLangToCookies = (lang) => {
cookie.save('lang', lang, { path: '/' })
}
5 changes: 4 additions & 1 deletion lib/notion/getPostBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ function filterPostBlocks(id, pageBlock, slice) {
}

// 如果是文件,或嵌入式PDF,需要重新加密签名
if ((b?.value?.type === 'file' || b?.value?.type === 'pdf' || b?.value?.type === 'video') && b?.value?.properties?.source?.[0][0]) {
if ((b?.value?.type === 'file' || b?.value?.type === 'pdf' || b?.value?.type === 'video' || b?.value?.type === 'audio') &&
b?.value?.properties?.source?.[0][0] &&
b?.value?.properties?.source?.[0][0].indexOf('amazonaws.com') > 0
) {
const oldUrl = b?.value?.properties?.source?.[0][0]
const newUrl = `https://notion.so/signed/${encodeURIComponent(oldUrl)}?table=block&id=${b?.value?.id}`
b.value.properties.source[0][0] = newUrl
Expand Down
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.1.3",
"version": "4.1.4",
"homepage": "https://github.com/tangly1024/NotionNext.git",
"license": "MIT",
"repository": {
Expand Down
10 changes: 9 additions & 1 deletion themes/simple/components/NavBar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { siteConfig } from '@/lib/config'
import { useRouter } from 'next/router'
import { useState } from 'react'
import { useSimpleGlobal } from '..'
import { MenuList } from './MenuList'

/**
Expand All @@ -10,9 +12,15 @@ import { MenuList } from './MenuList'
export default function NavBar (props) {
const [showSearchInput, changeShowSearchInput] = useState(false)
const router = useRouter()
const { searchModal } = useSimpleGlobal()

// 展示搜索框
const toggleShowSearchInput = () => {
changeShowSearchInput(!showSearchInput)
if (siteConfig('ALGOLIA_APP_ID')) {
searchModal.current.openSearch()
} else {
changeShowSearchInput(!showSearchInput)
}
}

const onKeyUp = (e) => {
Expand Down
18 changes: 15 additions & 3 deletions themes/simple/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import CONFIG from './config'
import { useEffect } from 'react'
import { createContext, useContext, useEffect, useRef } from 'react'
import { isBrowser } from '@/lib/utils'
import { useGlobal } from '@/lib/global'
import { AdSlot } from '@/components/GoogleAdsense'
Expand All @@ -10,7 +10,7 @@ import { Style } from './style'
import replaceSearchResult from '@/components/Mark'
import dynamic from 'next/dynamic'
import NotionPage from '@/components/NotionPage'
// const NotionPage = dynamic(() => import('@/components/NotionPage'), { ssr: false });
import AlgoliaSearchModal from '@/components/AlgoliaSearchModal'

// 主题组件
const BlogListScroll = dynamic(() => import('./components/BlogListScroll'), { ssr: false });
Expand All @@ -31,6 +31,10 @@ const CommonHead = dynamic(() => import('@/components/CommonHead'), { ssr: false
const WWAds = dynamic(() => import('@/components/WWAds'), { ssr: false });
const BlogListPage = dynamic(() => import('./components/BlogListPage'), { ssr: false })

// 主题全局状态
const ThemeGlobalSimple = createContext()
export const useSimpleGlobal = () => useContext(ThemeGlobalSimple)

/**
* 基础布局
*
Expand All @@ -40,8 +44,10 @@ const BlogListPage = dynamic(() => import('./components/BlogListPage'), { ssr: f
const LayoutBase = props => {
const { children, slotTop, meta } = props
const { onLoading, fullWidth } = useGlobal()
const searchModal = useRef(null)

return (
<ThemeGlobalSimple.Provider value={{ searchModal }}>
<div id='theme-simple' className='min-h-screen flex flex-col dark:text-gray-300 bg-white dark:bg-black'>
{/* SEO相关 */}
<CommonHead meta={meta}/>
Expand Down Expand Up @@ -88,9 +94,13 @@ const LayoutBase = props => {
<JumpToTopButton />
</div>

{/* 搜索框 */}
<AlgoliaSearchModal cRef={searchModal} {...props}/>

<Footer {...props} />

</div>
</ThemeGlobalSimple.Provider>
)
}

Expand Down Expand Up @@ -138,7 +148,9 @@ const LayoutSearch = props => {
}
}, [])

return <LayoutPostList {...props} slotTop={<SearchInput {...props} />} />
const slotTop = siteConfig('ALGOLIA_APP_ID') ? null : <SearchInput {...props} />

return <LayoutPostList {...props} slotTop={slotTop} />
}

/**
Expand Down

1 comment on commit 2a06e52

@vercel
Copy link

@vercel vercel bot commented on 2a06e52 Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.