Я пытаюсь интегрировать шаблон блога gatsby-starter-ghost с другим статическим шаблоном сайта под названием gatsby-serif-theme.
Я борюсь с несколькими вещами.
Как мне объединить два разных файла gatsby-config.js? я
я получаю довольно много ошибок здесь (я вставил консолидированный
Содержимое файла gatsby-config.js ниже в этом электронном письме).
Я могу без особых проблем собрать вместе файлы package.json из обоих проектов. Также размещено содержимое package.json ниже.
Мне также удалось создать новую папку под названием «Блог» под
Папка src / pages моего существующего статического сайта для gatsby-serif-themes
Обе темы имеют собственную схему внутри GraphQL.
Есть ли предписанный метод для выполнения этой интеграции?
Количество изменений конфигурации для сшивания вместе обеих тем может быть довольно сложным, особенно если у вас есть файлы конфигурации, такие как gatsby-config.js, gatsby-browser.js и gatsby-node.js, netlify.toml в обоих шаблоны и т. д.
Любые указатели в правильном направлении будут высоко оценены.
Ошибка:
error Мы столкнулись с ошибкой при попытке загрузить gatsby-config вашего сайта. TypeError: Невозможно уничтожить свойство apiUrl из «undefined» или «null».
/** gatsbyconfig.js **/
const guid = process.env.NETLIFY_GOOGLE_ANALYTICS_ID;
const path = require(path)
const config = require(./src/utils/siteConfig)
const generateRSSFeed = require(./src/utils/rss/generate-feed)
let ghostConfig
try {
ghostConfig = require(./.ghost)
} catch (e) {
ghostConfig = {
production: {
apiUrl: process.env.GHOST_API_URL,
contentApiKey: process.env.GHOST_CONTENT_API_KEY,
},
}
} finally {
const { apiUrl, contentApiKey } = process.env.NODE_ENV === development ? ghostConfig.development : ghostConfig.production
if (!apiUrl || !contentApiKey || contentApiKey.match(/<key>/)) {
throw new Error(GHOST_API_URL and GHOST_CONTENT_API_KEY are required to build. Check the README.) // eslint-disable-line
}
}
module.exports = {
siteMetadata: {
title: ‘Technovature Software’,
description: ‘Next Generation Innovation’,
contact: {
phone: ‘+91 7013175234’,
email: ‘info@technovature.com’,
address: ‘Hyderabad’,
},
menuLinks: [{
name: ‘Services’,
link: ‘/services’,
}, {
name: ‘OUR WORK’,
link: ‘/work’,
}, {
name: ‘About’,
link: ‘/about’,
}, {
name: ‘Blog’,
link: ‘/blog’,
}, {
name: ‘Testimonials’,
link: ‘/testimonials’,
}, {
name: ‘Contact’,
link: ‘/contact’,
},
],
},
plugins: [
‘gatsby-plugin-sass’,
‘gatsby-transformer-json’,
‘gatsby-transformer-remark’,
‘gatsby-plugin-react-helmet’,
{
resolve: ‘gatsby-source-filesystem’,
options: {
path: ${dirname}/src/pages,
name: ‘pages’,
},
}, {
resolve: ‘gatsby-source-filesystem’,
options: {
path: ${dirname}/src/data,
name: ‘data’,
},
}, {
resolve: ‘gatsby-source-filesystem’,
options: {
path: ${__dirname}/src/images,
name: ‘images’,
},
}, {
resolve: ‘gatsby-plugin-google-analytics’,
options: {
trackingId: guid ? guid : ‘UA-XXX-1’,
// Puts tracking script in the head instead of the body
head: false,
},
},
gatsby-plugin-sharp,
gatsby-transformer-sharp,
{
resolve: gatsby-source-ghost,
options:
process.env.NODE_ENV === development
? ghostConfig.development
: ghostConfig.production,
},
/** Utility Plugins */
{ resolve: gatsby-plugin-ghost-manifest, options: { short_name: config.shortTitle, start_url: /, background_color: config.backgroundColor, theme_color: config.themeColor, display: minimal-ui, icon: static/${config.siteIcon}, query: { allGhostSettings { edges { node { title description } } } }, }, }, { resolve: gatsby-plugin-feed, options: { query: { allGhostSettings { edges { node { title description } } } }, feeds: [ generateRSSFeed(config), ], }, }, { resolve: gatsby-plugin-advanced-sitemap, options: { query: { allGhostPost { edges { node { id slug updated_at created_at feature_image } } } allGhostPage { edges { node { id slug updated_at created_at feature_image } } } allGhostTag { edges { node { id slug feature_image } } } allGhostAuthor { edges { node { id slug profile_image } } } }, mapping: { allGhostPost: { sitemap: posts, }, allGhostTag: { sitemap: tags, }, allGhostAuthor: { sitemap: authors, }, allGhostPage: { sitemap: pages, }, }, exclude: [ /dev-404-page, /404, /404.html, /offline-plugin-app-shell-fallback, ], createLinkInHead: true, }, }, gatsby-plugin-force-trailing-slashes, gatsby-plugin-offline,
],
};
/** package.json file contents **/
{
"name": "gatsby-serif-theme",
"version": "1.0.0",
"author": "Robert Austin <rob@jugglerdigital.com>",
"license": "MIT",
"scripts": {
"develop": "gatsby develop",
"start": "npm run develop",
"build": "gatsby build",
"now-build": "npm run build",
"serve": "gatsby serve",
"lint": "eslint . --ext .js --cache",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@tryghost/helpers": "1.1.3",
"@tryghost/helpers-gatsby": "1.0.6",
"cheerio": "1.0.0-rc.3",
"@material-ui/core": "^3.9.3",
"core-js": "^3.1.2",
"gatsby": "^2.0.33",
"gatsby-awesome-pagination": "0.3.4",
"gatsby-image": "2.1.0",
"gatsby-plugin-advanced-sitemap": "1.0.6",
"gatsby-plugin-feed": "2.2.0",
"gatsby-plugin-force-trailing-slashes": "1.0.4",
"gatsby-plugin-manifest": "2.1.1",
"gatsby-plugin-offline": "2.1.1",
"gatsby-plugin-google-analytics": "^2.0.14",
"gatsby-plugin-react-helmet": "^3.0.4",
"gatsby-plugin-sass": "^2.0.7",
"gatsby-plugin-sharp": "2.0.37",
"gatsby-source-ghost": "3.3.2",
"gatsby-transformer-sharp": "2.1.19",
"lodash": "4.17.11",
"gatsby-source-filesystem": "^2.0.12",
"gatsby-transformer-json": "^2.1.6",
"gatsby-transformer-remark": "^2.1.15",
"google-map-react": "^1.1.4",
"google-maps-react": "^2.0.2",
"material-ui": "^0.20.2",
"node-sass": "^4.11.0",
"react": "^16.5.1",
"react-dom": "^16.8.6",
"react-helmet": "^5.2.0"
},
"devDependencies": {
"babel-eslint": "^9.0.0",
"eslint": "^5.5.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-ghost": "0.2.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-prettier": "^2.0.1",
"eslint-plugin-react": "^7.11.1",
"prettier-eslint": "^8.8.2"
}
}
/** gatsby-node.js file contents **/
const path = require('path');
// Create pages from markdown files
exports.createPages = ({ graphql, actions }) => {
const { createPage } = actions;
return new Promise((resolve, reject) => {
resolve(
graphql(
`
query {
services: allMarkdownRemark(
filter: { fileAbsolutePath: { regex: "/services/" } }
sort: { fields: [frontmatter___date], order: DESC }
) {
edges {
node {
id
frontmatter {
path
title
date(formatString: "DD MMMM YYYY")
}
excerpt
}
}
}
team: allMarkdownRemark(
filter: { fileAbsolutePath: { regex: "/team/" } }
sort: { fields: [frontmatter___date], order: DESC }
) {
edges {
node {
id
frontmatter {
path
title
date(formatString: "DD MMMM YYYY")
}
excerpt
}
}
}
testimonials: allMarkdownRemark(
filter: { fileAbsolutePath: { regex: "/testimonials/" } }
sort: { fields: [frontmatter___date], order: DESC }
) {
edges {
node {
id
frontmatter {
path
title
date(formatString: "DD MMMM YYYY")
}
excerpt
}
}
}
}
`,
).then((result) => {
result.data.services.edges.forEach(({ node }) => {
const component = path.resolve('src/templates/service.js');
createPage({
path: node.frontmatter.path,
component,
context: {
id: node.id,
},
});
});
result.data.team.edges.forEach(({ node }) => {
const component = path.resolve('src/templates/team.js');
createPage({
path: node.frontmatter.path,
component,
context: {
id: node.id,
},
});
});
result.data.testimonials.edges.forEach(({ node }) => {
const component = path.resolve('src/templates/testimonial.js');
createPage({
path: node.frontmatter.path,
component,
context: {
id: node.id,
},
});
});
resolve();
}),
);
});
};