mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-07 23:16:52 +00:00
sitemap,robots支持NOTION_CONFIG
This commit is contained in:
@@ -1,18 +1,18 @@
|
|||||||
|
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import BLOG from '@/blog.config'
|
import { siteConfig } from './config'
|
||||||
|
|
||||||
export async function generateRobotsTxt() {
|
export async function generateRobotsTxt(NOTION_CONFIG) {
|
||||||
|
const LINK = siteConfig('LINK', '', NOTION_CONFIG)
|
||||||
const content = `
|
const content = `
|
||||||
# *
|
# *
|
||||||
User-agent: *
|
User-agent: *
|
||||||
Allow: /
|
Allow: /
|
||||||
|
|
||||||
# Host
|
# Host
|
||||||
Host: ${BLOG.LINK}
|
Host: ${LINK}
|
||||||
|
|
||||||
# Sitemaps
|
# Sitemaps
|
||||||
Sitemap: ${BLOG.LINK}/sitemap.xml
|
Sitemap: ${LINK}/sitemap.xml
|
||||||
|
|
||||||
`
|
`
|
||||||
try {
|
try {
|
||||||
|
|||||||
15
lib/rss.js
15
lib/rss.js
@@ -1,4 +1,3 @@
|
|||||||
import BLOG from '@/blog.config'
|
|
||||||
import NotionPage from '@/components/NotionPage'
|
import NotionPage from '@/components/NotionPage'
|
||||||
import { getPostBlocks } from '@/lib/db/getSiteData'
|
import { getPostBlocks } from '@/lib/db/getSiteData'
|
||||||
import { Feed } from 'feed'
|
import { Feed } from 'feed'
|
||||||
@@ -27,22 +26,22 @@ const createFeedContent = async post => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function generateRss(NOTION_CONFIG, posts) {
|
export async function generateRss(NOTION_CONFIG, posts) {
|
||||||
const link = siteConfig('LINK', BLOG.LINK, NOTION_CONFIG)
|
const link = siteConfig('LINK', '', NOTION_CONFIG)
|
||||||
const author = siteConfig('AUTHOR', BLOG.AUTHOR, NOTION_CONFIG)
|
const author = siteConfig('AUTHOR', '', NOTION_CONFIG)
|
||||||
const lang = siteConfig('LANG', BLOG.LANG, NOTION_CONFIG)
|
const lang = siteConfig('LANG', '', NOTION_CONFIG)
|
||||||
const subPath = siteConfig('SUB_PATH', BLOG.SUB_PATH, NOTION_CONFIG)
|
const subPath = siteConfig('SUB_PATH', '', NOTION_CONFIG)
|
||||||
|
|
||||||
const year = new Date().getFullYear()
|
const year = new Date().getFullYear()
|
||||||
const feed = new Feed({
|
const feed = new Feed({
|
||||||
title: BLOG.TITLE,
|
title: siteConfig('TITLE', '', NOTION_CONFIG),
|
||||||
description: BLOG.DESCRIPTION,
|
description: siteConfig('DESCRIPTION', '', NOTION_CONFIG),
|
||||||
link: `${link}/${subPath}`,
|
link: `${link}/${subPath}`,
|
||||||
language: lang,
|
language: lang,
|
||||||
favicon: `${link}/favicon.png`,
|
favicon: `${link}/favicon.png`,
|
||||||
copyright: `All rights reserved ${year}, ${author}`,
|
copyright: `All rights reserved ${year}, ${author}`,
|
||||||
author: {
|
author: {
|
||||||
name: author,
|
name: author,
|
||||||
email: BLOG.CONTACT_EMAIL,
|
email: siteConfig('CONTACT_EMAIL', '', NOTION_CONFIG),
|
||||||
link: link
|
link: link
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export async function getStaticProps(req) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 生成robotTxt
|
// 生成robotTxt
|
||||||
generateRobotsTxt()
|
generateRobotsTxt(props?.NOTION_CONFIG)
|
||||||
// 生成Feed订阅
|
// 生成Feed订阅
|
||||||
if (JSON.parse(BLOG.ENABLE_RSS)) {
|
if (JSON.parse(BLOG.ENABLE_RSS)) {
|
||||||
generateRss(props?.NOTION_CONFIG, props?.latestPosts || [])
|
generateRss(props?.NOTION_CONFIG, props?.latestPosts || [])
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export const getServerSideProps = async ctx => {
|
|||||||
pageId: id,
|
pageId: id,
|
||||||
from: 'sitemap.xml'
|
from: 'sitemap.xml'
|
||||||
})
|
})
|
||||||
const link = siteConfig('LINK', BLOG.LINK, siteData.NOTION_CONFIG)
|
const link = siteConfig('LINK', '', siteData.NOTION_CONFIG)
|
||||||
const localeFields = generateLocalesSitemap(link, siteData.allPages, locale)
|
const localeFields = generateLocalesSitemap(link, siteData.allPages, locale)
|
||||||
fields = fields.concat(localeFields)
|
fields = fields.concat(localeFields)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user