fix: missing webmention token and use encodeURIComponent to keep share content format

This commit is contained in:
sy
2023-04-01 01:11:40 +08:00
parent 6f85b4d7ce
commit 2ff68a9d47
2 changed files with 4 additions and 3 deletions

View File

@@ -181,7 +181,8 @@ const BLOG = {
ENABLE: process.env.NEXT_PUBLIC_WEBMENTION_ENABLE || false, ENABLE: process.env.NEXT_PUBLIC_WEBMENTION_ENABLE || false,
AUTH: process.env.NEXT_PUBLIC_WEBMENTION_AUTH || '', AUTH: process.env.NEXT_PUBLIC_WEBMENTION_AUTH || '',
HOSTNAME: process.env.NEXT_PUBLIC_WEBMENTION_HOSTNAME || '', HOSTNAME: process.env.NEXT_PUBLIC_WEBMENTION_HOSTNAME || '',
TWITTER_USERNAME: process.env.NEXT_PUBLIC_TWITTER_USERNAME || '' TWITTER_USERNAME: process.env.NEXT_PUBLIC_TWITTER_USERNAME || '',
TOKEN: process.env.NEXT_PUBLIC_WEBMENTION_TOKEN || ''
}, },
// <---- 评论插件 // <---- 评论插件

View File

@@ -80,7 +80,7 @@ const WebmentionReplies = ({ target }) => {
const [mentions, setMentions] = useState([]) const [mentions, setMentions] = useState([])
const fetchMentions = async (target) => const fetchMentions = async (target) =>
fetch( fetch(
`https://webmention.io/api/mentions.jf2?per-page=500&target=${target}` `https://webmention.io/api/mentions.jf2?per-page=500&target=${target}&token=${BLOG.COMMENT_WEBMENTION.TOKEN}`
).then((response) => (response.json ? response.json() : response)) ).then((response) => (response.json ? response.json() : response))
useEffect(() => { useEffect(() => {
async function getMentions() { async function getMentions() {
@@ -153,7 +153,7 @@ const WebMentionBlock = ({ frontMatter }) => {
<a <a
target="_blank" target="_blank"
id='tweet-post-url' id='tweet-post-url'
href={`https://twitter.com/intent/tweet?text=${encodeURI(tweet)}`} href={`https://twitter.com/intent/tweet?text=${encodeURIComponent(tweet)}`}
rel="noopener noreferrer" rel="noopener noreferrer"
>tweet this post</a>{' '} >tweet this post</a>{' '}
or{' '} or{' '}