Open Cloufish opened 3 years ago
Hello @Cloufish, thanks for your issue.
Can you provide your gatsby-node.js
, gatsby-config.js
and markdown files ?
You can go to this example if you want inspiration : https://github.com/johackim/gatsby-remark-obsidian/tree/master/examples/remark
I'm so confused, so sorry ;_;. I've stumbled upon your repo from here -> https://github.com/mathieudutour/gatsby-digital-garden/issues/85. And I thought that It's just as easy as adding a new plugin into gatsby-config.js. Turns out it's not ;-;.
I've also tried using this theme from scratch, using your instructions (mostly! :smile: ): 1, Make a new directory and cd into it
npm install gatsby-remark-obsidian
npm install && npm start
gatsby-config.js
module.exports = {
plugins: [
{
resolve: 'gatsby-source-filesystem',
options: {
path: './content',
},
},
{
resolve: 'gatsby-transformer-remark',
options: {
plugins: [
{
resolve: 'gatsby-remark-obsidian',
options: {
titleToURL: (title) => `/${title}`,
},
},
],
},
},
],
};
gatsby-node.js
exports.createPages = async ({ actions, graphql, reporter }) => {
const { createPage } = actions;
const result = await graphql(`
{
allMarkdownRemark {
edges {
node {
id
html
parent {
... on File {
name
}
}
}
}
}
}
`);
if (result.errors) {
reporter.panicOnBuild('Error while running GraphQL query.');
return;
}
const markdowns = result.data.allMarkdownRemark.edges;
const noteTemplate = require.resolve('./src/templates/noteTemplate.js');
markdowns.forEach(({ node }) => {
const { id, html } = node;
createPage({
path: `/${node.parent.name}`,
component: noteTemplate,
context: { id, html },
});
});
};
Update - Wait, so is this a plugin or a theme? I managed to start one of the examples you provided, but it seems like the main purpose of this is to support aliases!
I went with the original plan - Adding the Plugin to the existing gatsby-digital-garden. What I've done is:
gatsby-config.js
, here're the contents the it:
module.exports = {
pathPrefix: `/knowledge-base`,
plugins: [
{
resolve: `gatsby-theme-garden`,
options: {
contentPath: `${__dirname}/content/garden`,
rootNote: `/HELLO-WORLD`,
},
resolve: "gatsby-transformer-remark",
options: {
plugins: [
{
resolve: 'gatsby-remark-obsidian',
options: {
titleToURL: (title) => `/${title}`, // optional
markdownFolder: `${__dirname}/content`, // optional
highlightClassName: 'highlight', // optional
},
},
]
},
}
],
siteMetadata: {
title: `Cloufish's Knowledge Base`,
},
}
- Adding `pathPrefix: ` parameter at the beginning is **optional**. I added It because It's the requirement in hosting the Page on GitHub Pages
1. Changed the gatsby dependency to latest the snippet under, to solve the issue of https://github.com/johackim/gatsby-remark-obsidian/issues/1
```js
"dependencies": {
"gatsby": "latest",
npm install gatsby-transformer-remark
and npm install gatsby-remark-obsidian
Failed to compile
There was an error in your GraphQL query:
Cannot query field "localSearchPaths" on type "Query".
If you don't expect "localSearchPaths" to exist on the type "Query" it is most likely a typo. However, if you expect "localSearchPaths" to exist there are a couple of solutions to common problems:
It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "Query": https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions
File: /home/cloufish/Projects/knowledge-base/node_modules/gatsby-theme-garden/src/use-search.js
There was an error in your GraphQL query:
Cannot query field "localSearchTitles" on type "Query".
If you don't expect "localSearchTitles" to exist on the type "Query" it is most likely a typo. However, if you expect "localSearchTitles" to exist there are a couple of solutions to common problems:
It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "Query": https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions
File: /home/cloufish/Projects/knowledge-base/node_modules/gatsby-theme-garden/src/use-search.js
There was an error in your GraphQL query:
Cannot query field "localSearchBodies" on type "Query".
If you don't expect "localSearchBodies" to exist on the type "Query" it is most likely a typo. However, if you expect "localSearchBodies" to exist there are a couple of solutions to common problems:
It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "Query": https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions
File: /home/cloufish/Projects/knowledge-base/node_modules/gatsby-theme-garden/src/use-search.js This error occurred during the build time and cannot be dismissed.
Don't know how to proceed from there. Pls I ask for help, over!
Try config for mdx plugin not gatsby-transformer-remark.
{
resolve: "gatsby-plugin-mdx",
options: {
extensions: [".md", ".mdx"],
gatsbyRemarkPlugins: [
{
resolve: "gatsby-remark-obsidian",
options: {
titleToURL: (title) => `/${title}`,
}
},
],
},
},
Note that using this creates normal <a>
link that does not providing stacking note functionality of gatsby-theme-garden
theme.
Why is that the case? :/ If there's any more information I can provide tell me