Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PRO-77] docs readme #5

Merged
merged 12 commits into from
May 21, 2024
Merged
28 changes: 28 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: 2
updates:
- package-ecosystem: "pnpm"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: fix
prefix-development: chore
include: scope
groups:
linting-dx-tools:
patterns:
- "*lint*" # eslint, eslint-*, vue-eslint-parser, lint-staged, @commitlint/*, @typescript-eslint/*
- "prettier"
- "husky"
- "@vue/tsconfig"
- "*babel*" # babel-*, @vue/babel-preset-app, @babel/*
update-types:
- "minor"
- "patch"
testing-tools:
patterns:
- "@vue/test-utils"
- "vitest"
update-types:
- "minor"
- "patch"
Binary file added .github/repo-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release CI

on:
push:
branches: [main, next, beta]
pull_request:
branches: [main, next, beta]

env:
PNPM_CACHE_FOLDER: .pnpm-store
HUSKY: 0 # Bypass husky commit hook for CI

jobs:
release:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Build lib
run: pnpm run build
- name: Test run
run: pnpm run test
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release@latest
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Run Tests
on: [push]

env:
PNPM_CACHE_FOLDER: .pnpm-store
HUSKY: 0 # Bypass husky commit hook for CI

jobs:
test:
name: Unit Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Run Unit Tests
run: pnpm run test
81 changes: 71 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,62 @@
# Storyblok Richtext Resolver PoC
![](/.github/repo-banner.png)

This is a proof of concept for a custom resolver for the Storyblok Richtext field. It is based on the [Storyblok Richtext Resolver](https://www.storyblok.com/docs/guide/rich-text-field) documentation.
<div align="center">
<h1>@storyblok/richtext</h1>
<p>
A custom resolver for the Storyblok Richtext field.
</p>
<br />
</div>

- [Proposal and PoC definition](https://www.notion.so/storyblok/RichText-d6334cacdd1946148a3992bcfca851a1?pvs=4)
- [Results of PoC](https://www.notion.so/storyblok/RichText-d6334cacdd1946148a3992bcfca851a1?pvs=4#37503f50422d41e29760fc5fc0dd91e2)
<p align="center">
<a href="https://npmjs.com/package/@storyblok/richtext">
<img src="https://img.shields.io/npm/v/@storyblok/richtext/latest.svg?style=flat-square" alt="Storyblok JS" />
</a>
<a href="https://npmjs.com/package/@storyblok/richtext" rel="nofollow">
<img src="https://img.shields.io/npm/dt/@storyblok/richtext.svg?style=flat-square" alt="npm">
</a>
</p>

## Usage
<p align="center">
<a href="https://discord.gg/jKrbAMz">
<img src="https://img.shields.io/discord/700316478792138842?label=Join%20Our%20Discord%20Community&style=appveyor&logo=discord&color=09b3af">
</a>
<a href="https://twitter.com/intent/follow?screen_name=storyblok">
<img src="https://img.shields.io/badge/Follow-%40storyblok-09b3af?style=appveyor&logo=twitter" alt="Follow @Storyblok" />
</a>
<a href="https://app.storyblok.com/#!/signup?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-richtext">
<img src="https://img.shields.io/badge/Try%20Storyblok-Free-09b3af?style=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAHqADAAQAAAABAAAAHgAAAADpiRU/AAACRElEQVRIDWNgGGmAEd3D3Js3LPrP8D8WXZwSPiMjw6qvPoHhyGYwIXNAbGpbCjbzP0MYuj0YFqMroBV/wCxmIeSju64eDNzMBJUxvP/9i2Hnq5cM1devMnz984eQsQwETeRhYWHgIcJiXqC6VHlFBjUeXgav40cIWkz1oLYXFmGwFBImaDFBHyObcOzdW4aSq5eRhRiE2dgYlpuYoYSKJi8vw3GgWnyAJIs/AuPu4scPGObd/fqVQZ+PHy7+6udPOBsXgySLDfn5GRYYmaKYJcXBgWLpsx8/GPa8foWiBhuHJIsl2DkYQqWksZkDFgP5PObcKYYff//iVAOTIDlx/QPqRMb/YSYBaWlOToZIaVkGZmAZSQiQ5OPtwHwacuo4iplMQEu6tXUZMhSUGDiYmBjylFQYvv/7x9B04xqKOnQOyT5GN+Df//8M59ASXKyMHLoyDD5JPtbj42OYrm+EYgg70JfuYuIoYmLs7AwMjIzA+uY/zjAnyWJpDk6GOFnCvrn86SOwmsNtKciVFAc1ileBHFDC67lzG10Yg0+SjzF0ownsf/OaofvOLYaDQJoQIGix94ljv1gIZI8Pv38zPvj2lQWYf3HGKbpDCFp85v07NnRN1OBTPY6JdRSGxcCw2k6sZuLVMZ5AV4s1TozPnGGFKbz+/PE7IJsHmC//MDMyhXBw8e6FyRFLv3Z0/IKuFqvFyIqAzd1PwBzJw8jAGPfVx38JshwlbIygxmYY43/GQmpais0ODDHuzevLMARHBcgIAQAbOJHZW0/EyQAAAABJRU5ErkJggg==" alt="Follow @Storyblok" />
</a>
</p>


## 🚀 Usage

> If you are first-time user of the Storyblok, read the [Getting Started](https://www.storyblok.com/docs/guide/getting-started?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-richtext) guide to get a project ready in less than 5 minutes.


### Installation

```bash
npm install @storyblok/richtext
```

or `yarn`:

```bash
yarn add @storyblok/richtext
```

or `pnpm`:

```bash
pnpm add @storyblok/richtext
```

### Basic

```ts
import { RichTextResolver } from '@storyblok/richtext-resolver'
import { RichTextResolver } from '@storyblok/richtext'

const { render } = RichTextResolver()

Expand All @@ -28,7 +74,7 @@ document.querySelector<HTMLDivElement>('#app')!.innerHTML = `
To overwrite an existing resolver, you can pass a property called resolvers available on the `RichTextResolver` options.

```ts
import { MarkTypes, RichTextResolver } from '@storyblok/richtext-resolver'
import { MarkTypes, RichTextResolver } from '@storyblok/richtext'

const html = RichTextResolver({
resolvers: {
Expand All @@ -47,7 +93,7 @@ It is possible to ensure correct typing support in a framework-agnostic way by u
- Vue `VNode`
- React `React.ReactElement`

This way the `@storyblok/richtext-resolver` is ignorant of framework specific types, avoiding having to import them and having `vue` `react` etc as dependencies.
This way the `@storyblok/richtext` is ignorant of framework specific types, avoiding having to import them and having `vue` `react` etc as dependencies.

```ts
// Vanilla
Expand Down Expand Up @@ -146,6 +192,21 @@ To run the tests for the core package:
pnpm run test
```

## License

[MIT](/LICENSE)
## 🔗 Related Links

- **[Storyblok Technology Hub](https://www.storyblok.com/technologies?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js)**: Storyblok integrates with every framework so that you are free to choose the best fit for your project. We prepared the technology hub so that you can find selected beginner tutorials, videos, boilerplates, and even cheatsheets all in one place.
- **[Getting Started](https://www.storyblok.com/docs/guide/getting-started?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js)**: Get a project ready in less than 5 minutes.
- **[Storyblok CLI](https://github.com/storyblok/storyblok)**: A simple CLI for scaffolding Storyblok projects and fieldtypes.

## ℹ️ More Resources

### Support

- Bugs or Feature Requests? [Submit an issue](/../../issues/new).
- Do you have questions about Storyblok or you need help? [Join our Discord Community](https://discord.gg/jKrbAMz).

### Contributing

Please see our [contributing guidelines](https://github.com/storyblok/.github/blob/main/contributing.md) and our [code of conduct](https://www.storyblok.com/trust-center#code-of-conduct?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js).
This project use [semantic-release](https://semantic-release.gitbook.io/semantic-release/) for generate new versions by using commit messages and we use the Angular Convention to naming the commits. Check [this question](https://semantic-release.gitbook.io/semantic-release/support/faq#how-can-i-change-the-type-of-commits-that-trigger-a-release) about it in semantic-release FAQ
15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@storyblok/richtext-resolver",
"name": "@storyblok/richtext",
"type": "module",
"version": "0.0.0",
"packageManager": "[email protected]",
Expand Down Expand Up @@ -109,6 +109,19 @@
"semi": true,
"singleQuote": false
},
"release": {
"branches": [
"main",
{
"name": "next",
"prerelease": true
},
{
"name": "beta",
"prerelease": true
}
]
},
"dependencies": {
"consola": "^3.2.3"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"dependencies": {
"@storyblok/react": "^3.0.9",
"@storyblok/richtext-resolver": "workspace:^",
"@storyblok/richtext": "workspace:^",
"@vitejs/plugin-react": "^4.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { StoryblokComponent } from '@storyblok/react'
import type { Node, SbRichtextOptions } from '@storyblok/richtext-resolver'
import { BlockTypes, RichTextResolver } from '@storyblok/richtext-resolver'
import type { Node, SbRichtextOptions } from '@storyblok/richtext'
import { BlockTypes, RichTextResolver } from '@storyblok/richtext'
import SbRichText from './SbRichText'

function componentResolver(node: Node<React.ReactElement>) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@storyblok/richtext-resolver": "workspace:^",
"@storyblok/richtext": "workspace:^",
"@storyblok/vue": "^8.0.7",
"vue": "^3.4.21",
"vue-router": "^4.3.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { VNode } from 'vue'
import { createTextVNode, h } from 'vue'
import { RouterLink } from 'vue-router'

import type { Node, NodeResolver, SbRichtextOptions } from '@storyblok/richtext-resolver'
import { BlockTypes, MarkTypes, RichTextResolver } from '@storyblok/richtext-resolver'
import type { Node, NodeResolver, SbRichtextOptions } from '@storyblok/richtext'
import { BlockTypes, MarkTypes, RichTextResolver } from '@storyblok/richtext'
import { StoryblokComponent } from '@storyblok/vue'
import SbRichText from './components/SbRichText.vue'

Expand Down
2 changes: 1 addition & 1 deletion playground/react/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RichTextResolver } from '@storyblok/richtext-resolver'
import { RichTextResolver } from '@storyblok/richtext'
import { StoryblokComponent, useStoryblok } from '@storyblok/react'
import { SbRichText } from '@storyblok/react-richtext'
import './App.css'
Expand Down
2 changes: 1 addition & 1 deletion playground/react/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default defineConfig({
],
resolve: {
alias: {
'@storyblok/richtext-resolver': resolve(__dirname, '../../src/index.ts'),
'@storyblok/richtext': resolve(__dirname, '../../src/index.ts'),
'@storyblok/react-richtext': resolve(__dirname, '../../packages/react/src/index.ts'),
},
},
Expand Down
2 changes: 1 addition & 1 deletion playground/vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"vite-plugin-qrcode": "^0.2.3"
},
"dependencies": {
"@storyblok/richtext-resolver": "workspace:^",
"@storyblok/richtext": "workspace:^",
"storyblok-js-client": "^6.7.1"
}
}
2 changes: 1 addition & 1 deletion playground/vanilla/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import './style.css'
import { MarkTypes, type Node, RichTextResolver, type SbRichtextOptions } from '@storyblok/richtext-resolver'
import { MarkTypes, type Node, RichTextResolver, type SbRichtextOptions } from '@storyblok/richtext'
import StoryblokClient from 'storyblok-js-client'

/* const doc: Node<string> = {
Expand Down
2 changes: 1 addition & 1 deletion playground/vanilla/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default defineConfig({
},
resolve: {
alias: {
'@storyblok/richtext-resolver': resolve(__dirname, '../../src/index.ts'),
'@storyblok/richtext': resolve(__dirname, '../../src/index.ts'),
},
},
})
2 changes: 1 addition & 1 deletion playground/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"@storyblok/richtext-resolver": "workspace:^",
"@storyblok/richtext": "workspace:^",
"@storyblok/vue": "^8.0.7",
"@storyblok/vue-richtext": "workspace:^",
"vue": "^3.4.21",
Expand Down
2 changes: 1 addition & 1 deletion playground/vue/src/components/HomeView.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { VNode, createTextVNode, h } from 'vue'
import { BlockTypes, MarkTypes, RichTextResolver, type Node, type SbRichtextOptions} from '@storyblok/richtext-resolver'
import { BlockTypes, MarkTypes, RichTextResolver, type Node, type SbRichtextOptions} from '@storyblok/richtext'
import { RouterLink } from 'vue-router'
import { SbRichText } from '@storyblok/vue-richtext'
import { useStoryblok } from '@storyblok/vue'
Expand Down
2 changes: 1 addition & 1 deletion playground/vue/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineConfig({
],
resolve: {
alias: {
'@storyblok/richtext-resolver': resolve(__dirname, '../../src/index.ts'),
'@storyblok/richtext': resolve(__dirname, '../../src/index.ts'),
'@storyblok/vue-richtext': resolve(__dirname, '../../packages/vue/src/index.ts'),
},
},
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading