diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..6b85964d --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,31 @@ +module.exports = { + env: { + browser: true, + es2021: true, + node: true + }, + extends: [ + 'plugin:react/recommended', + 'plugin:@next/next/recommended', + 'standard' + ], + parserOptions: { + ecmaFeatures: { + jsx: true + }, + ecmaVersion: 12, + sourceType: 'module' + }, + plugins: ['react'], + settings: { + react: { + version: 'detect' + } + }, + rules: { + 'react/prop-types': 'off' + }, + globals: { + React: true + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..e2267b04 --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env.local +.env.development.local +.env.test.local +.env.production.local + +# vercel +.vercel + +# sitemap +/public/robots.txt +/public/sitemap.xml +/data.json +/yarn.lock +.idea +.vscode diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 00000000..5f5ab6df --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "singleQuote": true, + "semi": false, + "trailingComma": "none", + "arrowParens": "avoid" +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..cc157ee6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021-present, tangly1024 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Nobelium-Logo.svg b/Nobelium-Logo.svg new file mode 100644 index 00000000..8275314e --- /dev/null +++ b/Nobelium-Logo.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/README.md b/README.md index 2c88d88e..ec615f9e 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,6 @@

-[中文说明 / [English](README.md)] - 演示地址:[https://www.tangly1024.com/](https://www.tangly1024.com/)
截图 diff --git a/blog.config.js b/blog.config.js new file mode 100644 index 00000000..4cd6807c --- /dev/null +++ b/blog.config.js @@ -0,0 +1,60 @@ +const BLOG = { + title: '塘里博客', + author: 'tangly', + email: 'tlyong1992@hotmail.com', + link: 'https://tangly1024.com', + description: '唐风集里,收卷波澜', + lang: 'zh-CN', // ['zh-CN','en-US'] + appearance: 'auto', // ['light', 'dark', 'auto'], + font: 'font-sans', // ['font-sans', 'font-serif', 'font-mono'] + lightBackground: '#ffffff', // use hex value, don't forget '#' e.g #fffefc + darkBackground: '#111827', // use hex value, don't forget '#' + path: '', // leave this empty unless you want to deploy in a folder + since: 2020, // if leave this empty, current year will be used. + postsPerPage: 6, + sortByDate: false, + showAbout: true, // WIP + showArchive: true, // WIP + autoCollapsedNavBar: false, // the automatically collapsed navigation bar + socialLink: 'https://weibo.com/u/2245301913', + seo: { + keywords: ['Blog', 'Website', 'Notion'], + googleSiteVerification: '' // Remove the value or replace it with your own google site verification code + }, + notionPageId: process.env.NOTION_PAGE_ID || 'bee1fccfa3bd47a1a7be83cc71372d83', // DO NOT CHANGE THIS!!! + notionAccessToken: process.env.NOTION_ACCESS_TOKEN || '', // Useful if you prefer not to make your database public + analytics: { + provider: 'ga', // Currently we support Google Analytics and Ackee, please fill with 'ga' or 'ackee', leave it empty to disable it. + ackeeConfig: { + tracker: '', // e.g 'https://ackee.tangly1024.net/tracker.js' + dataAckeeServer: '', // e.g https://ackee.tangly1024.net , don't end with a slash + domainId: '' // e.g '0e2257a8-54d4-4847-91a1-0311ea48cc7b' + }, + gaConfig: { + measurementId: 'G-5EV4HZD0XX' // e.g: G-XXXXXXXXXX + } + }, + comment: { + // support provider: gitalk, utterances, cusdis + provider: 'cusdis', // leave it empty if you don't need any comment plugin + gitalkConfig: { + repo: 'NotionNext', // The repository of store comments + owner: 'tangly1024', + admin: ['tangly1024'], + clientID: 'be7864a16b693e256f8f', + clientSecret: 'dbd0f6d9ceea8940f6ed20936b415274b8fe66a2', + distractionFreeMode: false + }, + cusdisConfig: { + appId: '445ba48e-f751-487f-b22f-cdbe3310d28f', // data-app-id + host: 'https://cusdis.com', // data-host, change this if you're using self-hosted version + scriptSrc: 'https://cusdis.com/js/cusdis.es.js' // change this if you're using self-hosted version + }, + utterancesConfig: { + repo: 'tangly1024/NotionNext' + } + }, + isProd: process.env.VERCEL_ENV === 'production' // distinguish between development and production environment (ref: https://vercel.com/docs/environment-variables#system-environment-variables) +} +// export default BLOG +module.exports = BLOG diff --git a/components/Ackee.js b/components/Ackee.js new file mode 100644 index 00000000..45d14d7a --- /dev/null +++ b/components/Ackee.js @@ -0,0 +1,14 @@ +import { useRouter } from 'next/router' +import useAckee from 'use-ackee' + +const Ackee = ({ ackeeServerUrl, ackeeDomainId }) => { + const router = useRouter() + useAckee( + router.asPath, + { server: ackeeServerUrl, domainId: ackeeDomainId }, + { detailed: false, ignoreLocalhost: true } + ) + return null +} + +export default Ackee diff --git a/components/BlogPost.js b/components/BlogPost.js new file mode 100644 index 00000000..8c40735a --- /dev/null +++ b/components/BlogPost.js @@ -0,0 +1,25 @@ +import BLOG from '@/blog.config' + +const BlogPost = ({ post }) => { + return ( +
+ {/* 封面图 */} + {post.page_cover && post.page_cover.length > 1 && ( + + {post.title} + + )} + +
+ + {post.title} + +

{post.summary}

+
+
+ ) +} + +export default BlogPost diff --git a/components/BlogPostMini.js b/components/BlogPostMini.js new file mode 100644 index 00000000..9b155ba2 --- /dev/null +++ b/components/BlogPostMini.js @@ -0,0 +1,24 @@ +import BLOG from '@/blog.config' + +const BlogPostMini = ({ post }) => { + return ( + + {/* 封面图 */} + {post.page_cover && post.page_cover.length > 1 && ( + {post.title} + )} + +
+ + {post.title} + +

{post.summary}

+

{BLOG.link}/article/{post.slug}

+
+ + ) +} + +export default BlogPostMini diff --git a/components/Comment.js b/components/Comment.js new file mode 100644 index 00000000..421738a7 --- /dev/null +++ b/components/Comment.js @@ -0,0 +1,67 @@ +import BLOG from '@/blog.config' +import dynamic from 'next/dynamic' +import { useRouter } from 'next/router' + +const GitalkComponent = dynamic( + () => { + return import('gitalk/dist/gitalk-component') + }, + { ssr: false } +) +const UtterancesComponent = dynamic( + () => { + return import('@/components/Utterances') + }, + { ssr: false } +) +const CusdisComponent = dynamic( + () => { + return import('react-cusdis').then(m => m.ReactCusdis) + }, + { ssr: false } +) + +const Comment = ({ frontMatter }) => { + const router = useRouter() + + return
+
留下评论
+ + {/* 评论插件 */} + {BLOG.comment.provider === 'gitalk' && ( + + )} + {BLOG.comment.provider === 'utterances' && ( + + )} + {BLOG.comment.provider === 'cusdis' && ( + <> + + )} + + {/* 统计脚本 */} + {BLOG.isProd && BLOG.analytics && BLOG.analytics.provider === 'ackee' && ( +