New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@githubnext/utils

Package Overview
Dependencies
Maintainers
4
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@githubnext/utils

To reduce the cognitive load associated with writing file and folder block components, we've assembled a helper library called `@githunext/utils` that exposes interface definitions and a few helper functions.

  • 0.23.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-80%
Maintainers
4
Weekly downloads
 
Created
Source

GitHub Blocks Utils Functions

To reduce the cognitive load associated with writing file and folder block components, we've assembled a helper library called @githunext/utils that exposes interface definitions and a few helper functions.

How to use

yarn add @githubnext/utils

import {
  FileBlockProps,
  FolderBlockProps,
  getLanguageFromFilename,
  getNestedFileTree,
} from '@githubnext/utils`

FileBlockProps

import { FileBlockProps } from '@githubnext/utils';

export default function (props: FileBlockProps) {
  const { content, metadata, onUpdateMetadata } = props;
  ...
}

FolderBlockProps

import { FolderBlockProps } from '@githubnext/utils';

export default function (props: FileBlockProps) {
  const { tree, metadata, onUpdateMetadata, BlockComponent } = props;
  ...
}

getLanguageFromFilename

A helper function that returns the "language" of a file, given a valid file path with extension.

getNestedFileTree

A helper function to turn the flat folder tree array into a nested tree structure

import { FolderBlockProps, getNestedFileTree, } from "@githubnext/utils";

export default function (props: FolderBlockProps) {
  const { tree, onNavigateToPath } = props;

  const data = useMemo(() => {
    const nestedTree = getNestedFileTree(tree)[0]
    return nestedTree
  }, [tree])
  ...
}

bundleCodesandboxFiles

A helper function to generate a bundle of files to send to CodeSandbox's Sandpack library. For an example, see the custom Block template repo.

onRequestGitHubData

A helper function to handle the onRequestGitHubData callback for Blocks. This function will GET data from any GitHub API endpoint.

FAQs

Package last updated on 11 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc