Skip to content

Commit

Permalink
Merge pull request #2700 from tangly1024/release/4.7.0
Browse files Browse the repository at this point in the history
Release/4.7.0
  • Loading branch information
tangly1024 authored Sep 5, 2024
2 parents d0a4acd + 1610ab6 commit 1ea503e
Show file tree
Hide file tree
Showing 21 changed files with 1,033 additions and 764 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.6.2
NEXT_PUBLIC_VERSION=4.7.0


# 可在此添加环境变量,去掉最左边的(# )注释即可
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ yarn-error.log*
/public/robots.txt
/public/sitemap.xml
/public/rss/*

/sitemap.xml

# yarn
package-lock.json
Expand Down
61 changes: 61 additions & 0 deletions components/OpenWrite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { siteConfig } from '@/lib/config'
import { isBrowser, loadExternalResource } from '@/lib/utils'
import { useEffect } from 'react'
/**
* OpenWrite公众号导流插件
* 使用介绍:https://openwrite.cn/guide/readmore/readmore.html#%E4%BA%8C%E3%80%81%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8
* 登录后台配置你的博客:https://readmore.openwrite.cn/
* @returns
*/
const OpenWrite = () => {
const qrcode = siteConfig('OPEN_WRITE_QRCODE', '请配置公众号二维码')
const blogId = siteConfig('OPEN_WRITE_BLOG_ID')
const name = siteConfig('OPEN_WRITE_NAME', '请配置公众号名')
const id = 'article-wrapper'
const keyword = siteConfig('OPEN_WRITE_KEYWORD', '请配置公众号关键词')
const btnText = siteConfig(
'OPEN_WRITE_BTN_TEXT',
'原创不易,完成人机检测,阅读全文'
)

const loadOpenWrite = async () => {
try {
await loadExternalResource(
'https://readmore.openwrite.cn/js/readmore-2.0.js',
'js'
)
const BTWPlugin = window?.BTWPlugin

if (BTWPlugin) {
const btw = new BTWPlugin()
window.btw = btw
btw.init({
qrcode,
id,
name,
btnText,
keyword,
blogId
})
}
} catch (error) {
console.error('OpenWrite 加载异常', error)
}
}

useEffect(() => {
if (isBrowser && blogId) {
// Check if the element with id 'read-more-wrap' already exists
const readMoreWrap = document.getElementById('read-more-wrap')

// Only load the script if the element doesn't exist
if (!readMoreWrap) {
loadOpenWrite()
}
}
})

return <></>
}

export default OpenWrite
2 changes: 1 addition & 1 deletion lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export function getLastPartOfUrl(url) {
* @param type js 或 css
* @returns {Promise<unknown>}
*/
export function loadExternalResource(url, type) {
export function loadExternalResource(url, type = 'js') {
// 检查是否已存在
const elements =
type === 'js'
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.6.2",
"version": "4.7.0",
"homepage": "https://github.com/tangly1024/NotionNext.git",
"license": "MIT",
"repository": {
Expand Down
7 changes: 6 additions & 1 deletion pages/[prefix]/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import BLOG from '@/blog.config'
import useNotification from '@/components/Notification'
import OpenWrite from '@/components/OpenWrite'
import { siteConfig } from '@/lib/config'
import { getGlobalData, getPost, getPostBlocks } from '@/lib/db/getSiteData'
import { useGlobal } from '@/lib/global'
Expand Down Expand Up @@ -95,8 +96,12 @@ const Slug = props => {
})
return (
<>
{/* 文章布局 */}
<Layout {...props} />
{/* 解锁密码提示框 */}
{post?.password && post?.password !== '' && !lock && <Notification />}
{/* 导流工具 */}
<OpenWrite />
</>
)
}
Expand Down Expand Up @@ -129,7 +134,7 @@ export async function getStaticProps({ params: { prefix }, locale }) {
fullSlug += '.html'
}
}

// 在列表内查找文章
props.post = props?.allPages?.find(p => {
return (
Expand Down
4 changes: 4 additions & 0 deletions styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,7 @@ a.avatar-wrapper {
margin-right: 20px;
}
}

img {
display: unset;
}
8 changes: 5 additions & 3 deletions themes/example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,12 @@ const LayoutSlug = props => {
{lock ? (
<PostLock validPassword={validPassword} />
) : (
<div id='article-wrapper'>
<div>
<PostMeta post={post} />
<NotionPage post={post} />
<ShareBar post={post} />
<div id='article-wrapper'>
<NotionPage post={post} />
<ShareBar post={post} />
</div>
<Comment frontMatter={post} />
</div>
)}
Expand Down
6 changes: 4 additions & 2 deletions themes/gitbook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,10 @@ const LayoutSlug = props => {

{/* Notion文章主体 */}
{post && (
<section id='article-wrapper' className='px-1'>
<NotionPage post={post} />
<section className='px-1'>
<div id='article-wrapper'>
<NotionPage post={post} />
</div>

{/* 分享 */}
<ShareBar post={post} />
Expand Down
9 changes: 6 additions & 3 deletions themes/heo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,17 @@ const LayoutSlug = props => {
return (
<>
<div
className={`article h-full w-full ${fullWidth ? '' : 'xl:max-w-5xl'} ${hasCode ? 'xl:w-[73.15vw]' : ''} lg:hover:shadow lg:border rounded-2xl lg:px-2 lg:py-4 bg-white dark:bg-[#18171d] dark:border-gray-600`}>
className={`article h-full w-full ${fullWidth ? '' : 'xl:max-w-5xl'} ${hasCode ? 'xl:w-[73.15vw]' : ''} bg-white dark:bg-[#18171d] dark:border-gray-600 lg:hover:shadow lg:border rounded-2xl lg:px-2 lg:py-4 `}>
{/* 文章锁 */}
{lock && <PostLock validPassword={validPassword} />}

{!lock && (
<div id='article-wrapper' className='mx-auto md:w-full md:px-5'>
<div className='mx-auto md:w-full md:px-5'>
{/* 文章主体 */}
<article itemScope itemType='https://schema.org/Movie'>
<article
id='article-wrapper'
itemScope
itemType='https://schema.org/Movie'>
{/* Notion文章主体 */}
<section
className='wow fadeInUp p-5 justify-center mx-auto'
Expand Down
5 changes: 2 additions & 3 deletions themes/hexo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,9 @@ const LayoutSlug = props => {
{lock && <ArticleLock validPassword={validPassword} />}

{!lock && (
<div
id='article-wrapper'
className='overflow-x-auto flex-grow mx-auto md:w-full md:px-5 '>
<div className='overflow-x-auto flex-grow mx-auto md:w-full md:px-5 '>
<article
id='article-wrapper'
itemScope
itemType='https://schema.org/Movie'
className='subpixel-antialiased overflow-y-hidden'>
Expand Down
Loading

0 comments on commit 1ea503e

Please sign in to comment.