johackim / gatsby-remark-obsidian

Gatsby plugin to support Obsidian markdown syntax
GNU General Public License v3.0
30 stars 10 forks source link

Issues With Setting Up Johackim Theme #2

Open Cloufish opened 3 years ago

Cloufish commented 3 years ago

image

image

Why is that the case? :/ If there's any more information I can provide tell me

johackim commented 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

Cloufish commented 3 years ago

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

  1. Run npm install gatsby-remark-obsidian
  2. Copied the contents of example's gatsby-config.js into my gatsby-config.js. Later I copied also gatsby-node.js
  3. Run npm install && npm start
    • And I got `missing script: "start" issue. And yeah I'm not surprised because the directory structure (right now) lacks compared to your remark examples!
    • image

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 },
        });
    });
};
Cloufish commented 3 years ago

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:

  1. Added the plugin into my 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",
  1. Then executes npm install gatsby-transformer-remark and npm install gatsby-remark-obsidian
  2. But I Got the GRAPHQL Issue :
    
    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!
vlwkaos commented 3 years ago

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.