├── .github
└── workflows
│ └── release.yaml
├── .gitignore
├── LICENSE.txt
├── README.md
├── blocks.config.json
├── blocks
├── example-file-block
│ ├── index.css
│ └── index.tsx
└── example-folder-block.tsx
├── package.json
├── release.ts
├── tsconfig.json
└── yarn.lock
/.github/workflows/release.yaml:
--------------------------------------------------------------------------------
1 | name: Create Release
2 | on:
3 | push:
4 | tags:
5 | - "*"
6 | jobs:
7 | build:
8 | runs-on: ubuntu-latest
9 | steps:
10 | - name: Checkout code
11 | uses: actions/checkout@v3
12 |
13 | - name: Set up Node.js
14 | uses: actions/setup-node@v3
15 | with:
16 | node-version: 18.x
17 | cache: yarn
18 |
19 | - name: Install dependencies
20 | run: yarn install --immutable
21 |
22 | - name: Compile assets
23 | run: yarn build
24 |
25 | - name: Create block tarballs
26 | run: node ./release.ts
27 |
28 | - name: Release
29 | uses: softprops/action-gh-release@v1
30 | with:
31 | files: dist/*.tar.gz
32 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .DS_Store
3 | dist-ssr
4 | *.local
5 | .yalc.lock
6 | .yalc
7 | dist
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright 2022 GitHub and contributors
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GitHub Blocks Template
2 |
3 | Use this repository as a starter template for building your own Blocks.
4 | ## Quickstart
5 |
6 | > 🛑 Currently, you must be flagged into the [GitHub Blocks Technical Preview](https://blocks.githubnext.com) in order to develop blocks. There is no "offline" development mode at this time.
7 |
8 | Fork this repo using the [`Use this template`](https://github.com/githubnext/blocks-template/generate) button above:
9 |
10 | 
11 |
12 | Then, clone _your_ repo (not [this one!](https://github.com/githubnext/blocks-template)) and get ready for action:
13 |
14 | ```bash
15 | yarn # install dependencies
16 | yarn start # start the dev server
17 | # Or use npm, pnpm, you know the drill
18 | ```
19 |
20 | When you visit [localhost:4000](https://localhost:4000) in your browser, you'll be
21 | redirected to the Blocks app, but your locally-developed blocks will appear in the block picker:
22 |
23 |
24 |
25 | (if you're using Safari (or another browser that doesn't permit calling `http` URLs from an `https` page), run `yarn start-https` and visit [https://localhost:4000](https://localhost:4000) instead.)
26 |
27 | This template includes one example File Block and one Folder Block. The dev server supports hot reloading, so make some changes, and see what they do!
28 |
29 | ## Under the hood
30 |
31 | Currently, Blocks are [React](https://reactjs.org/) components. They have a well-defined contract with their surroundings, and receive a [fixed set of props](https://github.com/githubnext/blocks/blob/main/docs/Developing%20blocks/4%20API%20reference%20and%20types.md) when they are instantiated. They are developed in [TypeScript](https://www.typescriptlang.org/), and bundled with [Vite](https://vitejs.dev/).
32 |
33 | ## More Info
34 |
35 | Visit [githubnext/blocks](https://blocks.githubnext.com/githubnext/blocks) for a full tutorial, documentation, and examples.
36 |
37 | You should also join us in our discord! There's a [#blocks channel](https://discord.com/channels/735557230698692749/1039950186136469535) where you can connect with us and other folks who are building Blocks:
38 |
39 | > 👋 https://discord.gg/githubnext
40 | ## License
41 |
42 | MIT
43 |
44 | ✌️ ❤️
45 | _GitHub Next_
46 |
--------------------------------------------------------------------------------
/blocks.config.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "type": "file",
4 | "id": "file-block",
5 | "title": "Example File Block",
6 | "description": "A basic file block",
7 | "entry": "blocks/example-file-block/index.tsx",
8 | "matches": ["*"],
9 | "example_path": "https://github.com/facebook/react/blob/main/packages/react-dom/index.js"
10 | },
11 | {
12 | "type": "folder",
13 | "id": "folder-block",
14 | "title": "Example Folder Block",
15 | "description": "A basic folder block",
16 | "entry": "blocks/example-folder-block.tsx",
17 | "matches": ["*"],
18 | "example_path": "https://github.com/githubocto/flat"
19 | }
20 | ]
21 |
--------------------------------------------------------------------------------
/blocks/example-file-block/index.css:
--------------------------------------------------------------------------------
1 | pre {
2 | background: papayawhip;
3 | }
4 |
--------------------------------------------------------------------------------
/blocks/example-file-block/index.tsx:
--------------------------------------------------------------------------------
1 | import { FileBlockProps, getLanguageFromFilename } from "@githubnext/blocks";
2 | import { Button, Box } from "@primer/react";
3 | import "./index.css";
4 |
5 | export default function ExampleFileBlock(props: FileBlockProps) {
6 | const { context, content, metadata, onUpdateMetadata } = props;
7 | const language = Boolean(context.path)
8 | ? getLanguageFromFilename(context.path)
9 | : "N/A";
10 |
11 | return (
12 |
13 |
20 |
27 | File: {context.path} {language}
28 |
29 |
30 |