Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into pr/1208nn/1700
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed Dec 27, 2023
2 parents 9492add + 11765e8 commit e79adb1
Show file tree
Hide file tree
Showing 15 changed files with 116 additions and 17 deletions.
4 changes: 2 additions & 2 deletions components/ExternalPlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const ExternalPlugin = (props) => {
{ANALYTICS_51LA_ID && ANALYTICS_51LA_CK && <LA51/>}

{ANALYTICS_51LA_ID && ANALYTICS_51LA_CK && (<>
<script charset="UTF-8" id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js" defer/>
<script id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js" defer/>
{/* <script async dangerouslySetInnerHTML={{
__html: `
LA.init({id:"${ANALYTICS_51LA_ID}",ck:"${ANALYTICS_51LA_CK}",hashMode:true,autoTrack:true})
Expand Down Expand Up @@ -139,7 +139,7 @@ const ExternalPlugin = (props) => {
/>
</>)}

{AD_WWADS_ID && <script type="text/javascript" charSet="UTF-8" src="https://cdn.wwads.cn/js/makemoney.js" async></script>}
{AD_WWADS_ID && <script type="text/javascript" src="https://cdn.wwads.cn/js/makemoney.js" async></script>}

{COMMENT_TWIKOO_ENV_ID && <script defer src={COMMENT_TWIKOO_CDN_URL} />}

Expand Down
10 changes: 8 additions & 2 deletions lib/lang/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default {
ARTICLE_DETAIL: 'Article Details',
PASSWORD_ERROR: 'Password Error!',
ARTICLE_LOCK_TIPS: 'Please Enter the password:',
NO_RESULTS_FOUND: 'No results found.',
SUBMIT: 'Submit',
POST_TIME: 'Post on',
LAST_EDITED_TIME: 'Last edited',
Expand All @@ -52,8 +53,8 @@ export default {
ANNOUNCEMENT: 'Announcement',
START_READING: 'Start Reading',
MINUTE: 'min',
WORD_COUNT: 'W.C.'

WORD_COUNT: 'Words',
READ_TIME: 'Read Time'
},
PAGINATION: {
PREV: 'Prev',
Expand All @@ -66,5 +67,10 @@ export default {
POST: {
BACK: 'Back',
TOP: 'Top'
},
MAILCHIMP: {
SUBSCRIBE: 'Subscribe',
MSG: 'Get the latest news and articles to your inbox every month.',
EMAIL: 'Email'
}
}
9 changes: 8 additions & 1 deletion lib/lang/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default {
VIEWS: '次查看',
COPYRIGHT_NOTICE: '本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。',
RESULT_OF_SEARCH: '篇搜索到的结果',
NO_RESULTS_FOUND: '没有找到文章',
ARTICLE_DETAIL: '文章详情',
PASSWORD_ERROR: '密码错误!',
ARTICLE_LOCK_TIPS: '文章已上锁,请输入访问密码',
Expand All @@ -54,7 +55,8 @@ export default {
ANNOUNCEMENT: '公告',
START_READING: '开始阅读',
MINUTE: '分钟',
WORD_COUNT: '字数'
WORD_COUNT: '字数',
READ_TIME: '阅读时长'
},
PAGINATION: {
PREV: '上页',
Expand All @@ -67,5 +69,10 @@ export default {
POST: {
BACK: '返回上页',
TOP: '回到顶部'
},
MAILCHIMP: {
SUBSCRIBE: '邮件订阅',
MSG: '订阅以获取每月更新的新闻和文章,直接发送至您的邮箱。',
EMAIL: '邮箱'
}
}
4 changes: 2 additions & 2 deletions pages/search/[keyword]/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const isIterable = obj =>
async function filterByMemCache(allPosts, keyword) {
const filterPosts = []
if (keyword) {
keyword = keyword.trim()
keyword = keyword.trim().toLowerCase()
}
for (const post of allPosts) {
const cacheKey = 'page_block_' + post.id
Expand All @@ -131,7 +131,7 @@ async function filterByMemCache(allPosts, keyword) {
if (!c) {
continue
}
const index = c.toLowerCase().indexOf(keyword.toLowerCase())
const index = c.toLowerCase().indexOf(keyword)
if (index > -1) {
hit = true
hitCount += 1
Expand Down
7 changes: 6 additions & 1 deletion themes/fukasawa/components/AsideLeft.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useFukasawaGlobal } from '..'
import CONFIG from '@/themes/fukasawa/config'
import { AdSlot } from '@/components/GoogleAdsense'
import { siteConfig } from '@/lib/config'
import MailChimpForm from './MailChimpForm'

/**
* 侧边栏
Expand Down Expand Up @@ -82,7 +83,11 @@ function AsideLeft(props) {
</section>

<section>
<AdSlot type='in-article'/>
<MailChimpForm />
</section>

<section>
<AdSlot type='in-article' />
</section>

{router.asPath !== '/tag' && <section className='flex flex-col'>
Expand Down
5 changes: 3 additions & 2 deletions themes/fukasawa/components/BlogCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const BlogCard = ({ index, post, showSummary, siteInfo }) => {
post.pageCoverThumbnail = siteInfo?.pageCover
}
const showPageCover = siteConfig('FUKASAWA_POST_LIST_COVER', null, CONFIG) && post?.pageCoverThumbnail
const SUB_PATH = siteConfig('SUB_PATH', '')

return (
<div
Expand All @@ -25,7 +26,7 @@ const BlogCard = ({ index, post, showSummary, siteInfo }) => {
{/* 封面图 */}
{showPageCover && (
<div className="flex-grow mb-3 w-full duration-200 cursor-pointer transform overflow-hidden">
<Link href={`${siteConfig('SUB_PATH', '')}/${post.slug}`} passHref legacyBehavior>
<Link href={`${SUB_PATH}/${post.slug}`} passHref legacyBehavior>
<LazyImage
src={post?.pageCoverThumbnail}
alt={post?.title || siteConfig('TITLE')}
Expand All @@ -37,7 +38,7 @@ const BlogCard = ({ index, post, showSummary, siteInfo }) => {

{/* 文字部分 */}
<div className="flex flex-col w-full">
<Link passHref href={`${siteConfig('SUB_PATH', '')}/${post.slug}`}
<Link passHref href={`${SUB_PATH}/${post.slug}`}
className={`break-words cursor-pointer font-bold hover:underline text-xl ${showPreview ? 'justify-center' : 'justify-start'} leading-tight text-gray-700 dark:text-gray-100 hover:text-blue-500 dark:hover:text-blue-400`}
>
{post.title}
Expand Down
4 changes: 3 additions & 1 deletion themes/fukasawa/components/BlogListEmpty.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { useGlobal } from '@/lib/global'

/**
* 空白博客 列表
* @returns {JSX.Element}
* @constructor
*/
const BlogListEmpty = ({ currentSearch }) => {
const { locale } = useGlobal()
return <div className='flex items-center justify-center min-h-screen mx-auto md:-mt-20'>
<p className='text-gray-500 dark:text-gray-300'>没有找到文章 {(currentSearch && <div>{currentSearch}</div>)}</p>
<p className='text-gray-500 dark:text-gray-300'>{locale.COMMON.NO_RESULTS_FOUND} {(currentSearch && <div>{currentSearch}</div>)}</p>
</div>
}
export default BlogListEmpty
62 changes: 62 additions & 0 deletions themes/fukasawa/components/MailChimpForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { useEffect, useRef, useState } from 'react'
import { subscribeToNewsletter } from '@/lib/mailchimp'
import { siteConfig } from '@/lib/config'
import CONFIG from '../config'
import { useGlobal } from '@/lib/global'

/**
* 邮件订阅表单
* @returns
*/
export default function MailChimpForm() {
const formRef = useRef()
const [success, setSuccess] = useState(false)
const { locale } = useGlobal()

useEffect(() => {
const form = formRef.current
const handleSubmit = (e) => {
e.preventDefault()
const email = document.querySelector('#newsletter').value
subscribeToNewsletter(email).then(response => {
console.log('Subscription succeeded:', response)
// 在此处添加成功订阅后的操作
setSuccess(true)
})
.catch(error => {
console.error('Subscription failed:', error)
// 在此处添加订阅失败后的操作
})
}
form?.addEventListener('submit', handleSubmit)
return () => {
form?.removeEventListener('submit', handleSubmit)
}
}, [subscribeToNewsletter])

return <>
{siteConfig('FUKASAWA_MAILCHIMP_FORM', null, CONFIG) && <div className="sm:col-span-6 md:col-span-3 lg:col-span-3">
<h6 className="text-gray-800 font-medium mb-2">{locale.MAILCHIMP.SUBSCRIBE}</h6>
<p className="text-sm text-gray-600 mb-4">{locale.MAILCHIMP.MSG}</p>
<form ref={formRef}>
<div className="flex flex-wrap mb-4">
<div className="w-full">
<label className="block text-sm sr-only" htmlFor="newsletter">{locale.MAILCHIMP.EMAIL}</label>
<div className="relative flex items-center max-w-xs">
<input disabled={success} id="newsletter" type="email" className="form-input w-full text-gray-800 px-3 py-2 pr-12 text-sm" placeholder={locale.MAILCHIMP.EMAIL} required />
<button disabled={success} type="submit" className="absolute inset-0 left-auto" aria-label="Subscribe">
<span className="absolute inset-0 right-auto w-px -ml-px my-2 bg-gray-300" aria-hidden="true"></span>
<svg className="w-3 h-3 fill-current text-blue-600 mx-3 shrink-0" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
<path d="M11.707 5.293L7 .586 5.586 2l3 3H0v2h8.586l-3 3L7 11.414l4.707-4.707a1 1 0 000-1.414z" fillRule="nonzero" />
</svg>
</button>
</div>
{/* Success message */}
{success && <p className="mt-2 text-green-600 text-sm">Thanks for subscribing!</p>}
</div>
</div>
</form>
</div>
}
</>
}
1 change: 1 addition & 0 deletions themes/fukasawa/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const CONFIG = {
FUKASAWA_MAILCHIMP_FORM: false, // 邮件订阅表单

FUKASAWA_POST_LIST_COVER: true, // 文章列表显示图片封面
FUKASAWA_POST_LIST_COVER_FORCE: false, // 即使没有封面也将站点背景图设置为封面
Expand Down
4 changes: 3 additions & 1 deletion themes/gitbook/components/NavPostListEmpty.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { useGlobal } from '@/lib/global'

/**
* 空白博客 列表
* @returns {JSX.Element}
* @constructor
*/
const NavPostListEmpty = ({ currentSearch }) => {
const { locale } = useGlobal()
return <div className='flex w-full items-center justify-center min-h-screen mx-auto md:-mt-20'>
<p className='text-gray-500 dark:text-gray-300'>没有找到文章 {(currentSearch && <div>{currentSearch}</div>)}</p>
<p className='text-gray-500 dark:text-gray-300'>{locale.COMMON.NO_RESULTS_FOUND} {(currentSearch && <div>{currentSearch}</div>)}</p>
</div>
}
export default NavPostListEmpty
4 changes: 3 additions & 1 deletion themes/medium/components/BlogPostListEmpty.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { useGlobal } from '@/lib/global'

/**
* 空白博客 列表
* @returns {JSX.Element}
* @constructor
*/
const BlogPostListEmpty = ({ currentSearch }) => {
const { locale } = useGlobal()
return <div className='flex w-full items-center justify-center min-h-screen mx-auto md:-mt-20'>
<p className='text-gray-500 dark:text-gray-300'>没有找到文章 {(currentSearch && <div>{currentSearch}</div>)}</p>
<p className='text-gray-500 dark:text-gray-300'>{locale.COMMON.NO_RESULTS_FOUND} {(currentSearch && <div>{currentSearch}</div>)}</p>
</div>
}
export default BlogPostListEmpty
4 changes: 3 additions & 1 deletion themes/nav/components/BlogPostListEmpty.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { useGlobal } from '@/lib/global'

/**
* 空白博客 列表
* @returns {JSX.Element}
* @constructor
*/
const BlogPostListEmpty = ({ currentSearch }) => {
const { locale } = useGlobal()
return <div className='flex w-full items-center justify-center min-h-screen mx-auto md:-mt-20'>
<p className='text-gray-500 dark:text-gray-300'>没有找到文章 {(currentSearch && <div>{currentSearch}</div>)}</p>
<p className='text-gray-500 dark:text-gray-300'>{locale.COMMON.NO_RESULTS_FOUND} {(currentSearch && <div>{currentSearch}</div>)}</p>
</div>
}
export default BlogPostListEmpty
4 changes: 3 additions & 1 deletion themes/nav/components/NavPostListEmpty.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { useGlobal } from '@/lib/global'

/**
* 空白博客 列表
* @returns {JSX.Element}
* @constructor
*/
const NavPostListEmpty = ({ currentSearch }) => {
const { locale } = useGlobal()
return <div className='flex w-full items-center justify-center min-h-screen mx-auto md:-mt-20'>
<p className='text-gray-500 dark:text-gray-300'>没有找到文章 {(currentSearch && <div>{currentSearch}</div>)}</p>
<p className='text-gray-500 dark:text-gray-300'>{locale.COMMON.NO_RESULTS_FOUND} {(currentSearch && <div>{currentSearch}</div>)}</p>
</div>
}
export default NavPostListEmpty
4 changes: 3 additions & 1 deletion themes/next/components/BlogPostListEmpty.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { useGlobal } from '@/lib/global'

/**
* 空白博客 列表
* @returns {JSX.Element}
* @constructor
*/
const BlogPostListEmpty = ({ currentSearch }) => {
const { locale } = useGlobal()
return <div className='flex items-center justify-center min-h-screen mx-auto md:-mt-20'>
<p className='text-gray-500 dark:text-gray-300'>没有找到文章 {(currentSearch && <div>{currentSearch}</div>)}</p>
<p className='text-gray-500 dark:text-gray-300'>{locale.COMMON.NO_RESULTS_FOUND} {(currentSearch && <div>{currentSearch}</div>)}</p>
</div>
}
export default BlogPostListEmpty
7 changes: 6 additions & 1 deletion themes/next/components/WordCount.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useGlobal } from '@/lib/global'
import { useEffect } from 'react'

/**
Expand All @@ -9,8 +10,12 @@ export default function WordCount() {
countWords()
})

const { locale } = useGlobal()

return <div id='wordCountWrapper' className='flex justify-center my-auto font-light'>
<i className='mr-1 fas fa-file-word my-auto' /> <span className='hidden md:block'>本文字数</span> <strong id='wordCount'>0</strong> &nbsp;|&nbsp; <i className='mr-1 fas fa-clock my-auto' /> <span className='hidden md:block'>阅读时长 ≈</span> <strong id='readTime'>0</strong> 分钟
<i className='mr-1 fas fa-file-word my-auto' />
<span className='hidden md:block'>{locale.COMMON.WORD_COUNT}</span>
<strong id='wordCount'>0</strong> &nbsp;|&nbsp; <i className='mr-1 fas fa-clock my-auto' />{locale.COMMON.READ_TIME} <span className='hidden md:block'></span> <strong id='readTime'>0</strong> {locale.COMMON.MINUTE}
</div>
}

Expand Down

0 comments on commit e79adb1

Please sign in to comment.