Giter VIP home page Giter VIP logo

theowenyoung / gatsby-theme-primer-wiki Goto Github PK

View Code? Open in Web Editor NEW
115.0 5.0 18.0 74.67 MB

A Gatsby Theme for Wiki/Docs/Knowledge Base, which using Primer style as the UI theme, can work well with Foam or Obsibian or just markdown files.

Home Page: https://demo-wiki.owenyoung.com/

License: MIT License

JavaScript 97.75% SCSS 1.28% Go 0.46% CSS 0.48% Shell 0.03%
gatsby foam knowledge-base obsidian wiki notes

gatsby-theme-primer-wiki's Introduction

Gatsby Theme Primer Wiki

A Gatsby Theme for Wiki/Docs/Knowledge Base, which using Primer style as the UI theme, can work well with Foam or Obsibian or just markdown files.

This theme is inspired with gatsby-project-kb, gatsby-digital-garden and doctocat

Sites that use this theme

Features

  • Support Local search, full-text search.
  • SEO Optimization
  • Support Graph Visualisation with Canvas.
  • Support Tags, Tags First, Generating tag pages, also connecting with graph visualisation.
  • Support Gitbook styled SUMMARY.md for custom sidebar.
  • Support [[WikiLink]]
  • Support Light/Dark Theme
  • Custom Header Nav Items
  • Nested Sidebar
  • Support Prefix Path
  • Support Draft Post

Principles

Here are my main ideas/principles in designing this theme.

  1. No vendor lock-in. The less vendor features you use, the better you'll be able to migrate. [[Wikilink]] is the only non-markdown feature supported by default, but nonetheless, it is recommended to use the standard markdown syntax, or if you edit with Foam, please use Wikilink with Link Reference Definitions. That give us the capability change our theme, or hosted place.
  2. Use meta data instead of special characters. We should use tags as the document's metadata, not #tag in the plain text.
  3. Use tags instead of categories. Minimal subfolders.

Getting Started

With Foam template repo

See foam-template-gatsby-theme-primer-wiki

With the Obsidian template repo

See obsidian-template-gatsby-theme-primer-wiki

With the Gatsby starter

See gatsby-starter-primer-wiki

Manual

npm i gatsby-theme-primer-wiki

Usage

Theme Config

Edit gatsby-config.js

If you use foam template, edit .layouts/gatsby-config.js

Example:

    {
      resolve: "gatsby-theme-primer-wiki",
      options: {
        sidebarDepth: 0,
        nav: [
          {
            title: "Github",
            url: "https://github.com/theowenyoung/gatsby-theme-primer-wiki",
          },
        ],
        editUrl: `https://github.com/theowenyoung/gatsby-theme-primer-wiki/tree/main/`,
      },
    },

A valid config can be found here

nav

For header navs. Support two depth levels. Example:

{
  nav: [
    {
      title: "Github",
      url: "https://github.com",
    },
    {
      title: "Menus",
      items: [
        {
          title: "Menu1",
          url: "https://google.com",
        },
      ],
    },
  ];
}

editUrl

You remote git repo url prefix.

mdxOtherwiseConfigured

Advanced, use your own mdx plugin config, See https://github.com/theowenyoung/gatsby-theme-primer-wiki/blob/main/theme/gatsby-config.js#L31-L67

Prefix Path

See here

Logo

You can use icon as your site logo path. Example:

{
  "icon": "static/icon.png"
}

Others

{
      nav: [],
      mdxOtherwiseConfigured: false, // advanced, use your own mdx plugin config, See https://github.com/theowenyoung/gatsby-theme-primer-wiki/blob/main/theme/gatsby-config.js
      remarkPlugins: [], // add gatsby-plugin-mdx remarkPlugins
      rehypePlugins: [], // add gatsby-plugin-mdx rehypePlugins
      gatsbyRemarkPlugins: [], // add gatsby-plugin-mdx gatsbyRemarkPlugins
      extensions: [`.mdx`, ".md", ".markdown"], // supported file extensions for mdx
      sidebarDefault: "auto", // first summary -> tags -> files tree , value can be auto, summary, tag, category
      sidebarComponents: [], // custom sitebar components, value can be summary, latest, tag, category, example: ["summary", "latest", "tag"], if this be defined, sidebarDefault will not work.
      imageMaxWidth: 561, // max width for image
      contentMaxWidth: 1440, // max width for content, include right sidebar
      sidebarDepth: 0, // sidebar depth, default is 0;
      summaryDepth: 1, // specify summary depth if exist
      summary1DepthIndent: false, // specify summary depth 0 indent, default false, not indent, when depth>1, it will indent
      editUrl: "", // github/gitlab editurl, with prefix, example: 'https://github.com/facebook/docusaurus/edit/main/website/',
      editUrlText: "Edit this page", // edit url text
      shouldShowLastUpdated: true, // should show last updated
      latestUpdatedText: "Recently Updated",
      shouldShowTagGroupsOnIndex: true, // should show tags list at index page
      shouldSupportTags: true, // whether support tags
      tagText: "Tags",
      categoryText: "Categories",
      shouldSupportLatest: true, // whether support latest posts, if true, theme will generate /latest/ page show latest updated posts.
      shouldShowLatestOnIndex: true, // should show latest posts on index,
      defaultIndexLatestPostCount: 10, // default latest posts on index count, default is 25
      rewriteUrlFileIgnore: [], // not rewrite `xxx.md`  to `xxx`
      rewriteToParentUrlFileIgnore: [], // not add parent path join for the file
      defaultColorMode: "day", // default color mode, auto, night, day
      lastUpdatedTransformer: (isoString) => {
        const dateObj = new Date(isoString);
        const date = dateObj.toLocaleString("en-US", {
          day: "numeric",
          month: "numeric",
          year: "numeric",
        });
        return date;
      },
      lastUpdatedText: "Last updated on",
    }

Custom Sidebars

Create a file named SUMMARY.md in your content directory, for the format, just following the Gitbook docs.

You can set a custom default sidebar depth using sidebarDepth, the default value is 0

Custom Theme

You can overwrite all site theme by add src/gatsby-theme-primer-wiki/theme.js

const theme = {
  colorSchemes: {
    light: {
      colors: {
        text: {
          primary: "red",
        },
      },
    },
  },
};

export default theme;

See the default primer theme at here

Todos

  • - excerpt as seo description
  • - support mobile instant view button
  • - support nav items
  • - support graph view
  • - release workflow
  • - readme add summary
  • - pathPrefix test
  • - qbittorrent with jackett mobile screen overflow
  • - support tags search
  • - support theme
  • - Docs
  • - Obsidian Support
  • - Theme auto mdx provider not apply dark mode
  • - Show latest updates
  • - theme custom

Screenshot

Home

Index

Backlinks & Tags

Footer

Graph Visualisation

Footer

Dark Theme

Dark Theme

gatsby-theme-primer-wiki's People

Contributors

dfeng avatar github-actions[bot] avatar padosum avatar theowenyoung avatar zubayrrr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gatsby-theme-primer-wiki's Issues

Unable to see Backlinks

Hello,
I want to say thank you for this theme.
I'm using it well for learning. It's really nice. 😄

I recenlty discovered that "Backlinks (ReferencesBlock)" doesn't work.
Since I don't know much about Gatsby, I kept trying to console.log again again again...
In my opinion, in references/lib/compute-inbounds.jsfile,

function getInboundReferences(getNode, allNodes) {
  const nodes = allNodes;
  const slugs = Array.from(nodes.map((node) => node.fields.slug));

  const inboundReferences = {};
  function filterNodes(item) {
    return slugs.includes(item);
  }

  nodes.forEach((node) => {
    const mapped = node.__outboundReferencesSlugs // slug array
      .filter(filterNodes)
      .map((x) => x.id); // no id attribute

node._outboundReferencesSlugs has only slug values, so in the map, 'id' is undefined.

If my thinking is correct, is it okay to modify it and make a pull request?

Cannot query field "fbAppId" on type "SiteSiteMetadata".

It seems that the new version of this theme requires to add "fbAppID" in the site metadata.

Here is the error message:
Screenshot (11)

Is there a typo and the attribute should be in SiteMetadata instead of SiteSiteMetadata?

What should happen if I do not have a fbAppid ?

Latex support

Would it be possible to directly add latex support through gatsby-remark-katex in this theme?

Thanks for the great theme !

Sourcing from Strapi

Hi,

Once again, many thanks from my team for your great job and theme.

I'm facing an issue I can't resolve by myself, any help or hint would be greatly appreciated.

Problem

When sourcing from Strapi, the Gatsby Theme Primer Wiki can't generate the pages anymore, landing on 404.

Expected

Being able to source from Strapi, and being able to run Gatsby.

Steps to reproduce

  1. Start a new project : gatsby new wiki https://github.com/theowenyoung/gatsby-starter-primer-wiki

  2. In project root : npx create-strapi-app@latest backend --quickstart // this will create the Strapi backend in /backend

Now in Strapi (http://localhost:1337/admin):

  1. Create a Single Type ('Homepage' in my case), put some dummy content in, save, publish

  2. Settings / Users & Permissions Plugin -> give 'find' Permission to 'Public' and to 'Authentificated' on the previously selected Single Type

  3. create an API Token with FULL ACCESS and copy it for later use

  4. Restart strapi (in /backend) : yarn start develop

And now in Gatsby :

  1. npm install --save gatsby-source-strapi gatsby-plugin-image gatsby-plugin-sharp gatsby-source-filesystem gatsby-transformer-remark gatsby-transformer-sharp // https://www.gatsbyjs.com/plugins/gatsby-source-strapi/

  2. gatsby-config.js, add :

const strapiConfig = {
  apiURL: 'http://localhost:1337',
  accessToken: 'your-token',
  collectionTypes: [],
  singleTypes: ['homepage'],
};

and

{
      resolve: `gatsby-source-strapi`,
      options: strapiConfig,
},
  1. gatsby-clean
  2. gatsby-develop

You should see many issues in the Terminal. Looks like the Theme is not able to generate pages anymore and it lands to 404. See complete log

Some observations

Even if Gatsby crashes, I can see my strapiHomepage nodes in http://localhost:8000/__graphql ; sourcing seems to work.

In gatsby-config.js, changing the singleTypes['homepage'] by any dummy singleType, let's say singleTypes['dummyType'] doesn't generate the error.

My config

Gatsby CLI version: 4.16.0
Gatsby version: 4.6.0
Node v16.15.1
Strapi 3.1.0-alpha.5

Distributor ID: Ubuntu
Description: Ubuntu 22.04 LTS
Release: 22.04
Codename: jammy

Did I miss something huge or is it something with the theme ? Any hint of help to fix this would be greatly appreciated.

Have a great day,
Grégoire

Syntax Highlighting

I am a programming student and am actively using this template to store all my programming related notes. I love everything about it and have had no issues setting it up thanks to the great documentation. However, I was unable to find any mention or support for code syntax highlighting. Is this a supported feature and just needs to be enabled or does it need to be implemented? This would be a huge help to me.

Error generating sites when reading `inboundReferences`

I've been running into this in a few cases. I've been looking at moving my Obsidian published site over to this, but every time I try to set it up I get the following error when starting the server.

This is happening when using the Obsidian template, and when using the starter, both with my files in place, and with the default demo content present in the starter.

I'm running Node 16.14.0

I'm not particularly familiar with GraphQL, so sorry that I'm not coming with more debug info.

 ERROR #85901  GRAPHQL                                                                                                    
                                                                                                                          
There was an error in your GraphQL query:                                                                                 
                                                                                                                          
Cannot read properties of undefined (reading 'filter')
                                                                                                                          
   1 | query pathToRepoLayoutsnodeModulesgatsbyThemePrimerWikisrcuseNoteGraphDataJs2320115945 {
   2 |   allMdx {
   3 |     nodes {                                                      
   4 |       fields {                                  
   5 |         title                                                       
   6 |         slug                                                                                                       
   7 |       }                                                                                                                                                                                                                                       
>  8 |       inboundReferences {                 
     |       ^                                
   9 |         ... on Mdx {                                                                                               
  10 |           fields {                                                                                                 
  11 |             title                                                                                                  
  12 |             slug                                            
  13 |           }                              
  14 |         }                           
  15 |       }                                                                                                            
  16 |       outboundReferences {
  17 |         ... on Mdx {                                                                                               
  18 |           fields {                              
                                                                                                                          
File path: /Users/user/repo/.layouts/node_modules/gatsby-theme-primer-wiki/src/use-note-graph-data.js
Plugin: none                                                                                                              
                                                                                                                          
                                                                                                                          
                                                                                                                          
  TypeError: Cannot read properties of undefined (reading 'filter')                                                                                                                                                                                  
                                                        
  - node-model.js:266 LocalNodeModel._query           
    [.layouts]/[gatsby]/src/schema/node-model.js:266:21                                                                   
                                               
  - node-model.js:327 LocalNodeModel.findAll                                                                              
    [.layouts]/[gatsby]/src/schema/node-model.js:327:47            
                                                                                                                          
  - node-model.js:599 ContextualNodeModel.findAll
    [.layouts]/[gatsby]/src/schema/node-model.js:599:27                                                                   
                                                      
  - create-schema-customization.js:57 resolver                                                                            
    [.layouts]/[@theowenyoung]/gatsby-transformer-references/lib/create-schema-customization.js:57:12
                               
  - resolvers.ts:668 resolver                    
    [.layouts]/[gatsby]/src/schema/resolvers.ts:668:20 
                     
  - resolvers.ts:668 wrappedTracingResolver   
    [.layouts]/[gatsby]/src/schema/resolvers.ts:668:20                                                                    
                                                                                                                          
  - Array.map                                                                                                                                                                                                                                        
                                                      
                                                                                                                          
success run static queries - 0.071s - 4/4 56.55/s                                                                         
success run page queries - 0.010s - 2/2 198.22/s                                                                          
⠀                                                                                                                         
You can now view wiki in the browser.                                                                                     
⠀                                         
  Local:            http://localhost:8000/                                                                                
  On Your Network:  http://192.168.50.195:8000/        
⠀                                                                                                                         
View GraphiQL, an in-browser IDE, to explore your site's data and schema
⠀                                                         
  Local:            http://localhost:8000/___graphql                       
  On Your Network:  http://192.168.50.195:8000/___graphql                                                                 
⠀                                                                                                                                                                                                                                                    
Note that the development build is not optimized.
To create a production build, use gatsby build

RFC: Consider adding note colouring to graphView

Motivation

When organizing note, we can have semantic kind of node.

Eg some note about "Book", some about "Thought", etc...

Allowing the user to see the colors make it easier to find the information on the graph

image

(You can see in the previous image that foam on vscode already support node coloring since foambubble/foam#438.)

{
  "foam.graph.style": {
    "node": {
      "concept": "#3b82f6",
      "technology": "#8b5cf6",
      "kaizen discovery report": "#f43f5e",
      "tag": "#14b8a6"
    }
  }
 }

User explanation

  • user would provide an optional type property in .md file
---
title: CPU Bound
type: concept
tags:
  - Concept
---
  • user would provide an optional customGraphStyle in config
module.exports = {
  plugins: [
    {
      resolve: "gatsby-theme-primer-wiki",
      options: {
+       "customGraphStyle": {"concept: "#3b82f6"}
      },
    },
  ]
}

Technical explanation

image

The above example code is:

() => {
  const localNotes: Note[] = CONCEPT_DATA.map((o, i) => ({
    ...o,
    type: ['JS Lib', 'Visualization'].includes(o.title) ? 'tag' : 'note',
  }))

  const noteGraphNote = localNotes.find((o) => o.title === 'Note Graph')
  noteGraphNote.nodeStyle = {
    regular: '#E94780',
  }
  const graphModel = new NoteGraphModel(localNotes)

  const tagStyle: NodeStyle = {
    regular: '#64BB00',
    lessened: 'rgba(101, 189, 0, 0.6)',
    highlighted: 'green',
  }

  const localStyle = {
    node: {
      /** Set different style for nodes with `tag` type */
      tag: tagStyle,
    },
  }
  return (
    <div>
      <GraphView
        graphModel={graphModel}
        style={localStyle}
        onGraphViewInit={(view) => {
          if (noteGraphNote) {
            view.setSelectedNodes([noteGraphNote.id])
          }
        }}
      ></GraphView>
    </div>
  )
}

Why not do this

  • initial work => I would like to contribute that it is easier for you to review external code (some open source project found it harder to review code that doing themself)
  • maintenance work => it should be rather separated from rest of the code so it should impact codebase too much

Unresolved question

  • Should we support dark theme in config, eg
module.exports = {
  plugins: [
    {
      resolve: "gatsby-theme-primer-wiki",
      options: {
+       "customGraphStyle": {"concept: {"dark": "#5eead4", "light": "#0f766e"}}
      },
    },
  ]
}
  • Maybe type conflict with other property so we may pick another name (eg "graphType" and map over the node to rename it just for the graph)

  • Would you prefer a contribution (later this week) or would you prefer to do it yourself ?

context with inboundReference

Hi,

Firstly, just wanted to say that I'm really enjoying this theme – so thanks for all the work you've put into it!

One of the things I like in https://github.com/mathieudutour/gatsby-digital-garden is that the inboundReferences include the context (e.g. here), whereas your implementation simply shows that there exists an inbound reference. My current "digital garden" uses https://github.com/andymatuschak/note-link-janitor, which also provides the context.

I've been looking at the code, though I'm not particularly familiar with js/gatsby/remark. Would it be easy to enable this feature? I'm happy to work on it as an excuse to learn some js.

improve QoL Sidebar Category

I like the folder approach of obsidian and usually organize it through the folder structure.
Currently the Sidebar Category Component doesn't remember which of the menuitems are opened and resets after clicking a link.

Is it possible to update the sidebar category component so it remembers the opened menuitems?
Overall especially useful for the obsidian theme.

My Current set up is through github pages.

thanks in advance!

rehypePlugins?

Any possibility of getting the rehypePlugins parameter on top of remarkPlugins for mdx?

working with mermaid

Hey! Thanks again for doing this theme!

One question I have is re use of mermaid diagrams. I set up the remark mermaid plugin and installed both gatsby-remark, remark-mermaid, and puppeteer (see versions below), but the snippets are rendered just as snippets, not diagrams. Am I missing something, or there are issues between the theme, foam, and gatsby?

 "dependencies": {
    "foam-cli": "^0.11.0",
    "gatsby": "^3.12.0",
    "gatsby-plugin-manifest": "^3.12.0",
    "gatsby-remark-mermaid": "^2.1.0",
    "gatsby-source-filesystem": "^3.12.0",
    "gatsby-theme-primer-wiki": "^1.13.1",
    "gatsby-transformer-remark": "^4.0.0",
    "puppeteer": "^11.0.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "sharp": "^0.29.1"
  }

Side list from the note

Is there any way to extract certain section from the note (or it's metadata) into a side bar (e.g. down below the content on the right side)?

I usually have "links" section which clutters space but nice to have at hand...

同学,您这个项目引入了1494个开源组件,存在7个漏洞,辛苦升级一下

检测到 theowenyoung/gatsby-theme-primer-wiki 一共引入了1494个开源组件,存在7个漏洞

漏洞标题:object-path 安全漏洞
缺陷组件:[email protected]
漏洞编号:CVE-2021-23434
漏洞描述:object-path是个人开发者的一个可以通过路径访问数据结构中变量的 Npm 库。
object-path 0.11.6之前版本存在安全漏洞,该漏洞源于当path参数中使用的路径组件是阵列时会导致类型混淆漏洞。
影响范围:(∞, 0.11.6)
最小修复版本:0.11.6
缺陷组件引入路径:[email protected]>[email protected]

另外还有7个漏洞,详细报告:https://mofeisec.com/jr?p=a8a765

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.