├── .changeset ├── README.md ├── config.json ├── long-panthers-retire.md ├── pre.json └── tricky-pugs-yell.md ├── .editorconfig ├── .eslintrc.js ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .husky ├── commit-msg ├── pre-commit └── prepare-commit-msg ├── .prettierrc ├── .vscode ├── extensions.json └── settings.json ├── .yarn ├── install-state.gz ├── plugins │ └── @yarnpkg │ │ ├── plugin-version.cjs │ │ └── plugin-workspace-tools.cjs └── releases │ └── yarn-3.5.1.cjs ├── .yarnrc.yml ├── LICENSE ├── README.md ├── apps └── docs │ ├── .eslintrc │ ├── .gitignore │ ├── .lintstagedrc.js │ ├── .vscode │ └── settings.json │ ├── CHANGELOG.md │ ├── README.md │ ├── contentlayer.config.js │ ├── next.config.js │ ├── package.json │ ├── postcss.config.js │ ├── public │ ├── next.svg │ └── vercel.svg │ ├── src │ └── app │ │ ├── Sidebar.tsx │ │ ├── blocks │ │ ├── [slug] │ │ │ └── page.tsx │ │ └── page.tsx │ │ ├── guides │ │ └── [slug] │ │ │ └── page.tsx │ │ ├── head.tsx │ │ ├── layout.tsx │ │ ├── page.tsx │ │ ├── plugins │ │ └── [slug] │ │ │ └── page.tsx │ │ ├── styles.scss │ │ └── styles │ │ ├── _blocks.scss │ │ ├── blocks │ │ ├── bookmark.scss │ │ ├── bulleted-list.scss │ │ ├── callout.scss │ │ ├── code.scss │ │ ├── columns.scss │ │ ├── divider.scss │ │ ├── headings.scss │ │ ├── images.scss │ │ ├── numbered-list.scss │ │ ├── paragraph.scss │ │ ├── quote.scss │ │ ├── table.scss │ │ ├── to-do.scss │ │ ├── toggle-heading.scss │ │ └── toggle.scss │ │ ├── mixins │ │ └── _colors.scss │ │ └── variables │ │ └── _colors.scss │ ├── tailwind.config.js │ └── tsconfig.json ├── commitlint.config.js ├── package.json ├── packages ├── .gitkeep ├── client │ ├── .lintstagedrc │ ├── CHANGELOG.md │ ├── package.json │ ├── sass │ │ ├── _blocks.scss │ │ ├── blocks │ │ │ ├── bookmark.scss │ │ │ ├── bulleted-list.scss │ │ │ ├── callout.scss │ │ │ ├── code.scss │ │ │ ├── columns.scss │ │ │ ├── divider.scss │ │ │ ├── headings.scss │ │ │ ├── images.scss │ │ │ ├── numbered-list.scss │ │ │ ├── paragraph.scss │ │ │ ├── quote.scss │ │ │ ├── table.scss │ │ │ ├── to-do.scss │ │ │ ├── toggle-heading.scss │ │ │ └── toggle.scss │ │ ├── mixins │ │ │ └── _colors.scss │ │ ├── theme.scss │ │ └── variables │ │ │ └── _colors.scss │ ├── src │ │ ├── blocks │ │ │ ├── bookmark-block.renderer.ts │ │ │ ├── bulleted-list-block.renderer.ts │ │ │ ├── bulleted-list-item-block.renderer.ts │ │ │ ├── callout-block.renderer.ts │ │ │ ├── code-block.renderer.ts │ │ │ ├── column-block.renderer.ts │ │ │ ├── column-list-block.renderer.ts │ │ │ ├── divider-block.renderer.ts │ │ │ ├── emoji-block.renderer.ts │ │ │ ├── heading1-block.renderer.ts │ │ │ ├── heading2-block.renderer.ts │ │ │ ├── heading3-block.renderer.ts │ │ │ ├── image-block.renderer.ts │ │ │ ├── mention-block.renderer.ts │ │ │ ├── numbered-list-block.renderer.ts │ │ │ ├── numbered-list-item-block.renderer.ts │ │ │ ├── paragraph-block.renderer.ts │ │ │ ├── quote-block.renderer.ts │ │ │ ├── table-block.renderer.ts │ │ │ ├── table-row.renderer.ts.ts │ │ │ ├── text-block.renderer.ts │ │ │ ├── to-do-block.renderer.ts │ │ │ ├── to-do-list-block.renderer.ts │ │ │ └── toggle-block.renderer.ts │ │ ├── extensions │ │ │ ├── bulleted-list.extension.ts │ │ │ ├── numbered-list.extension.ts │ │ │ └── to-do-list.extension.ts │ │ ├── globals.ts │ │ ├── index.ts │ │ ├── notion-renderer.ts │ │ ├── plugin.ts │ │ ├── types.ts │ │ └── utils │ │ │ └── create-block-renderer.ts │ ├── tsconfig.json │ └── types.d.ts └── plugins │ ├── bookmark │ ├── .lintstagedrc │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── project.json │ ├── src │ │ └── index.ts │ └── tsconfig.json │ └── hljs │ ├── .lintstagedrc │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ └── index.ts │ └── tsconfig.json ├── tsconfig.base.json ├── tsconfig.json ├── turbo.json └── yarn.lock /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": false, 5 | "fixed": [], 6 | "linked": [], 7 | "access": "public", 8 | "baseBranch": "main", 9 | "updateInternalDependencies": "patch", 10 | "ignore": [ 11 | "docs" 12 | ] 13 | } -------------------------------------------------------------------------------- /.changeset/long-panthers-retire.md: -------------------------------------------------------------------------------- 1 | --- 2 | '@notion-render/bookmark-plugin': patch 3 | '@notion-render/hljs-plugin': patch 4 | '@notion-render/client': patch 5 | --- 6 | 7 | Fix dependencies linking due to monorepository 8 | -------------------------------------------------------------------------------- /.changeset/pre.json: -------------------------------------------------------------------------------- 1 | { 2 | "mode": "pre", 3 | "tag": "alpha", 4 | "initialVersions": { 5 | "@notion-render/client": "0.0.1-alpha.0", 6 | "@notion-render/bookmark-plugin": "0.0.1-alpha.0", 7 | "@notion-render/hljs-plugin": "0.0.1-alpha.0", 8 | "docs": "0.0.1-alpha.1" 9 | }, 10 | "changesets": [ 11 | "long-panthers-retire", 12 | "tricky-pugs-yell" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /.changeset/tricky-pugs-yell.md: -------------------------------------------------------------------------------- 1 | --- 2 | '@notion-render/bookmark-plugin': patch 3 | '@notion-render/hljs-plugin': patch 4 | '@notion-render/client': patch 5 | --- 6 | 7 | Refactor monorepository 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | module.exports = { 3 | plugins: ['@typescript-eslint', 'simple-import-sort'], 4 | parser: '@typescript-eslint/parser', 5 | ignorePatterns: ['**/dist/*'], 6 | extends: [ 7 | 'turbo', 8 | 'eslint:recommended', 9 | 'plugin:@typescript-eslint/recommended', 10 | 'plugin:@typescript-eslint/recommended-requiring-type-checking', 11 | 'prettier', 12 | ], 13 | rules: { 14 | 'simple-import-sort/imports': 'error', 15 | '@typescript-eslint/no-explicit-any': 'off', 16 | '@typescript-eslint/no-non-null-assertion': 'off', 17 | '@typescript-eslint/restrict-template-expressions': 'off', 18 | '@typescript-eslint/require-await': 'off', 19 | '@typescript-eslint/no-unsafe-member-access': 'off', 20 | }, 21 | parserOptions: { 22 | tsconfigRootDir: __dirname, 23 | project: ['./packages/**/tsconfig.json', '/apps/*/tsconfig.json'], 24 | }, 25 | root: true, 26 | }; 27 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: ['**'] 6 | pull_request: 7 | branches: ['**'] 8 | 9 | env: 10 | HUSKY: 0 11 | 12 | jobs: 13 | main: 14 | name: Main 15 | timeout-minutes: 15 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v3 20 | with: 21 | fetch-depth: 0 22 | - name: Setup Node.js environment 23 | uses: actions/setup-node@v3 24 | with: 25 | node-version: 18 26 | cache: 'yarn' 27 | - name: Install dependencies 28 | run: | 29 | yarn install 30 | - name: Build 31 | run: yarn build --filter="@notion-render/*" 32 | - name: Lint 33 | run: yarn lint --filter="@notion-render/*" 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | dist 5 | tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | node_modules 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | yarn-error.log 34 | testem.log 35 | /typings 36 | 37 | # System Files 38 | .DS_Store 39 | Thumbs.db 40 | 41 | # Next.js 42 | .next 43 | .vercel 44 | 45 | .pnp.* 46 | .yarn/* 47 | !.yarn/patches 48 | !.yarn/plugins 49 | !.yarn/releases 50 | !.yarn/sdks 51 | !.yarn/versions 52 | 53 | # Turbo 54 | .turbo -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | yarn commitlint --edit "$1" 5 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | yarn lint-staged 5 | -------------------------------------------------------------------------------- /.husky/prepare-commit-msg: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | exec < /dev/tty && node_modules/.bin/cz --hook || true 5 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": true, 6 | "singleQuote": true, 7 | "trailingComma": "es5", 8 | "bracketSpacing": true, 9 | "jsxSingleQuote": false, 10 | "arrowParens": "always", 11 | "proseWrap": "never", 12 | "htmlWhitespaceSensitivity": "strict", 13 | "endOfLine": "lf" 14 | } -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "nrwl.angular-console", 4 | "esbenp.prettier-vscode", 5 | "dbaeumer.vscode-eslint", 6 | "firsttris.vscode-jest-runner" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "search.exclude": { 3 | "**/dist": true, 4 | "**/.turbo": true 5 | }, 6 | "files.exclude": { 7 | "**/dist": true, 8 | "**/.turbo": true, 9 | "**/.vercel": true, 10 | "**/.husky": true, 11 | "**/.yarn": true 12 | }, 13 | "editor.codeActionsOnSave": { 14 | "source.fixAll.eslint": false 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.yarn/install-state.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kerwanp/notion-render/d5107bf20244d355e193d2ed914839d65c74e29c/.yarn/install-state.gz -------------------------------------------------------------------------------- /.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | //prettier-ignore 3 | module.exports = { 4 | name: "@yarnpkg/plugin-workspace-tools", 5 | factory: function (require) { 6 | var plugin=(()=>{var yr=Object.create;var we=Object.defineProperty;var _r=Object.getOwnPropertyDescriptor;var Er=Object.getOwnPropertyNames;var br=Object.getPrototypeOf,xr=Object.prototype.hasOwnProperty;var W=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(r,t)=>(typeof require<"u"?require:r)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var q=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Cr=(e,r)=>{for(var t in r)we(e,t,{get:r[t],enumerable:!0})},Je=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of Er(r))!xr.call(e,s)&&s!==t&&we(e,s,{get:()=>r[s],enumerable:!(n=_r(r,s))||n.enumerable});return e};var Be=(e,r,t)=>(t=e!=null?yr(br(e)):{},Je(r||!e||!e.__esModule?we(t,"default",{value:e,enumerable:!0}):t,e)),wr=e=>Je(we({},"__esModule",{value:!0}),e);var ve=q(ee=>{"use strict";ee.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;ee.find=(e,r)=>e.nodes.find(t=>t.type===r);ee.exceedsLimit=(e,r,t=1,n)=>n===!1||!ee.isInteger(e)||!ee.isInteger(r)?!1:(Number(r)-Number(e))/Number(t)>=n;ee.escapeNode=(e,r=0,t)=>{let n=e.nodes[r];!n||(t&&n.type===t||n.type==="open"||n.type==="close")&&n.escaped!==!0&&(n.value="\\"+n.value,n.escaped=!0)};ee.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;ee.isInvalidBrace=e=>e.type!=="brace"?!1:e.invalid===!0||e.dollar?!0:e.commas>>0+e.ranges>>0===0||e.open!==!0||e.close!==!0?(e.invalid=!0,!0):!1;ee.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;ee.reduce=e=>e.reduce((r,t)=>(t.type==="text"&&r.push(t.value),t.type==="range"&&(t.type="text"),r),[]);ee.flatten=(...e)=>{let r=[],t=n=>{for(let s=0;s{"use strict";var tt=ve();rt.exports=(e,r={})=>{let t=(n,s={})=>{let i=r.escapeInvalid&&tt.isInvalidBrace(s),a=n.invalid===!0&&r.escapeInvalid===!0,c="";if(n.value)return(i||a)&&tt.isOpenOrClose(n)?"\\"+n.value:n.value;if(n.value)return n.value;if(n.nodes)for(let p of n.nodes)c+=t(p);return c};return t(e)}});var st=q((Vn,nt)=>{"use strict";nt.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var ht=q((Jn,pt)=>{"use strict";var at=st(),le=(e,r,t)=>{if(at(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(r===void 0||e===r)return String(e);if(at(r)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let n={relaxZeros:!0,...t};typeof n.strictZeros=="boolean"&&(n.relaxZeros=n.strictZeros===!1);let s=String(n.relaxZeros),i=String(n.shorthand),a=String(n.capture),c=String(n.wrap),p=e+":"+r+"="+s+i+a+c;if(le.cache.hasOwnProperty(p))return le.cache[p].result;let m=Math.min(e,r),h=Math.max(e,r);if(Math.abs(m-h)===1){let y=e+"|"+r;return n.capture?`(${y})`:n.wrap===!1?y:`(?:${y})`}let R=ft(e)||ft(r),f={min:e,max:r,a:m,b:h},$=[],_=[];if(R&&(f.isPadded=R,f.maxLen=String(f.max).length),m<0){let y=h<0?Math.abs(h):1;_=it(y,Math.abs(m),f,n),m=f.a=0}return h>=0&&($=it(m,h,f,n)),f.negatives=_,f.positives=$,f.result=Sr(_,$,n),n.capture===!0?f.result=`(${f.result})`:n.wrap!==!1&&$.length+_.length>1&&(f.result=`(?:${f.result})`),le.cache[p]=f,f.result};function Sr(e,r,t){let n=Pe(e,r,"-",!1,t)||[],s=Pe(r,e,"",!1,t)||[],i=Pe(e,r,"-?",!0,t)||[];return n.concat(i).concat(s).join("|")}function vr(e,r){let t=1,n=1,s=ut(e,t),i=new Set([r]);for(;e<=s&&s<=r;)i.add(s),t+=1,s=ut(e,t);for(s=ct(r+1,n)-1;e1&&c.count.pop(),c.count.push(h.count[0]),c.string=c.pattern+lt(c.count),a=m+1;continue}t.isPadded&&(R=Lr(m,t,n)),h.string=R+h.pattern+lt(h.count),i.push(h),a=m+1,c=h}return i}function Pe(e,r,t,n,s){let i=[];for(let a of e){let{string:c}=a;!n&&!ot(r,"string",c)&&i.push(t+c),n&&ot(r,"string",c)&&i.push(t+c)}return i}function $r(e,r){let t=[];for(let n=0;nr?1:r>e?-1:0}function ot(e,r,t){return e.some(n=>n[r]===t)}function ut(e,r){return Number(String(e).slice(0,-r)+"9".repeat(r))}function ct(e,r){return e-e%Math.pow(10,r)}function lt(e){let[r=0,t=""]=e;return t||r>1?`{${r+(t?","+t:"")}}`:""}function kr(e,r,t){return`[${e}${r-e===1?"":"-"}${r}]`}function ft(e){return/^-?(0+)\d/.test(e)}function Lr(e,r,t){if(!r.isPadded)return e;let n=Math.abs(r.maxLen-String(e).length),s=t.relaxZeros!==!1;switch(n){case 0:return"";case 1:return s?"0?":"0";case 2:return s?"0{0,2}":"00";default:return s?`0{0,${n}}`:`0{${n}}`}}le.cache={};le.clearCache=()=>le.cache={};pt.exports=le});var Ue=q((es,Et)=>{"use strict";var Or=W("util"),At=ht(),dt=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Nr=e=>r=>e===!0?Number(r):String(r),Me=e=>typeof e=="number"||typeof e=="string"&&e!=="",Ae=e=>Number.isInteger(+e),De=e=>{let r=`${e}`,t=-1;if(r[0]==="-"&&(r=r.slice(1)),r==="0")return!1;for(;r[++t]==="0";);return t>0},Ir=(e,r,t)=>typeof e=="string"||typeof r=="string"?!0:t.stringify===!0,Br=(e,r,t)=>{if(r>0){let n=e[0]==="-"?"-":"";n&&(e=e.slice(1)),e=n+e.padStart(n?r-1:r,"0")}return t===!1?String(e):e},gt=(e,r)=>{let t=e[0]==="-"?"-":"";for(t&&(e=e.slice(1),r--);e.length{e.negatives.sort((a,c)=>ac?1:0),e.positives.sort((a,c)=>ac?1:0);let t=r.capture?"":"?:",n="",s="",i;return e.positives.length&&(n=e.positives.join("|")),e.negatives.length&&(s=`-(${t}${e.negatives.join("|")})`),n&&s?i=`${n}|${s}`:i=n||s,r.wrap?`(${t}${i})`:i},mt=(e,r,t,n)=>{if(t)return At(e,r,{wrap:!1,...n});let s=String.fromCharCode(e);if(e===r)return s;let i=String.fromCharCode(r);return`[${s}-${i}]`},Rt=(e,r,t)=>{if(Array.isArray(e)){let n=t.wrap===!0,s=t.capture?"":"?:";return n?`(${s}${e.join("|")})`:e.join("|")}return At(e,r,t)},yt=(...e)=>new RangeError("Invalid range arguments: "+Or.inspect(...e)),_t=(e,r,t)=>{if(t.strictRanges===!0)throw yt([e,r]);return[]},Mr=(e,r)=>{if(r.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},Dr=(e,r,t=1,n={})=>{let s=Number(e),i=Number(r);if(!Number.isInteger(s)||!Number.isInteger(i)){if(n.strictRanges===!0)throw yt([e,r]);return[]}s===0&&(s=0),i===0&&(i=0);let a=s>i,c=String(e),p=String(r),m=String(t);t=Math.max(Math.abs(t),1);let h=De(c)||De(p)||De(m),R=h?Math.max(c.length,p.length,m.length):0,f=h===!1&&Ir(e,r,n)===!1,$=n.transform||Nr(f);if(n.toRegex&&t===1)return mt(gt(e,R),gt(r,R),!0,n);let _={negatives:[],positives:[]},y=T=>_[T<0?"negatives":"positives"].push(Math.abs(T)),E=[],S=0;for(;a?s>=i:s<=i;)n.toRegex===!0&&t>1?y(s):E.push(Br($(s,S),R,f)),s=a?s-t:s+t,S++;return n.toRegex===!0?t>1?Pr(_,n):Rt(E,null,{wrap:!1,...n}):E},Ur=(e,r,t=1,n={})=>{if(!Ae(e)&&e.length>1||!Ae(r)&&r.length>1)return _t(e,r,n);let s=n.transform||(f=>String.fromCharCode(f)),i=`${e}`.charCodeAt(0),a=`${r}`.charCodeAt(0),c=i>a,p=Math.min(i,a),m=Math.max(i,a);if(n.toRegex&&t===1)return mt(p,m,!1,n);let h=[],R=0;for(;c?i>=a:i<=a;)h.push(s(i,R)),i=c?i-t:i+t,R++;return n.toRegex===!0?Rt(h,null,{wrap:!1,options:n}):h},$e=(e,r,t,n={})=>{if(r==null&&Me(e))return[e];if(!Me(e)||!Me(r))return _t(e,r,n);if(typeof t=="function")return $e(e,r,1,{transform:t});if(dt(t))return $e(e,r,0,t);let s={...n};return s.capture===!0&&(s.wrap=!0),t=t||s.step||1,Ae(t)?Ae(e)&&Ae(r)?Dr(e,r,t,s):Ur(e,r,Math.max(Math.abs(t),1),s):t!=null&&!dt(t)?Mr(t,s):$e(e,r,1,t)};Et.exports=$e});var Ct=q((ts,xt)=>{"use strict";var Gr=Ue(),bt=ve(),qr=(e,r={})=>{let t=(n,s={})=>{let i=bt.isInvalidBrace(s),a=n.invalid===!0&&r.escapeInvalid===!0,c=i===!0||a===!0,p=r.escapeInvalid===!0?"\\":"",m="";if(n.isOpen===!0||n.isClose===!0)return p+n.value;if(n.type==="open")return c?p+n.value:"(";if(n.type==="close")return c?p+n.value:")";if(n.type==="comma")return n.prev.type==="comma"?"":c?n.value:"|";if(n.value)return n.value;if(n.nodes&&n.ranges>0){let h=bt.reduce(n.nodes),R=Gr(...h,{...r,wrap:!1,toRegex:!0});if(R.length!==0)return h.length>1&&R.length>1?`(${R})`:R}if(n.nodes)for(let h of n.nodes)m+=t(h,n);return m};return t(e)};xt.exports=qr});var vt=q((rs,St)=>{"use strict";var Kr=Ue(),wt=He(),he=ve(),fe=(e="",r="",t=!1)=>{let n=[];if(e=[].concat(e),r=[].concat(r),!r.length)return e;if(!e.length)return t?he.flatten(r).map(s=>`{${s}}`):r;for(let s of e)if(Array.isArray(s))for(let i of s)n.push(fe(i,r,t));else for(let i of r)t===!0&&typeof i=="string"&&(i=`{${i}}`),n.push(Array.isArray(i)?fe(s,i,t):s+i);return he.flatten(n)},Wr=(e,r={})=>{let t=r.rangeLimit===void 0?1e3:r.rangeLimit,n=(s,i={})=>{s.queue=[];let a=i,c=i.queue;for(;a.type!=="brace"&&a.type!=="root"&&a.parent;)a=a.parent,c=a.queue;if(s.invalid||s.dollar){c.push(fe(c.pop(),wt(s,r)));return}if(s.type==="brace"&&s.invalid!==!0&&s.nodes.length===2){c.push(fe(c.pop(),["{}"]));return}if(s.nodes&&s.ranges>0){let R=he.reduce(s.nodes);if(he.exceedsLimit(...R,r.step,t))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let f=Kr(...R,r);f.length===0&&(f=wt(s,r)),c.push(fe(c.pop(),f)),s.nodes=[];return}let p=he.encloseBrace(s),m=s.queue,h=s;for(;h.type!=="brace"&&h.type!=="root"&&h.parent;)h=h.parent,m=h.queue;for(let R=0;R{"use strict";Ht.exports={MAX_LENGTH:1024*64,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:` 7 | `,CHAR_NO_BREAK_SPACE:"\xA0",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:" ",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}});var Nt=q((ss,Ot)=>{"use strict";var jr=He(),{MAX_LENGTH:Tt,CHAR_BACKSLASH:Ge,CHAR_BACKTICK:Fr,CHAR_COMMA:Qr,CHAR_DOT:Xr,CHAR_LEFT_PARENTHESES:Zr,CHAR_RIGHT_PARENTHESES:Yr,CHAR_LEFT_CURLY_BRACE:zr,CHAR_RIGHT_CURLY_BRACE:Vr,CHAR_LEFT_SQUARE_BRACKET:kt,CHAR_RIGHT_SQUARE_BRACKET:Lt,CHAR_DOUBLE_QUOTE:Jr,CHAR_SINGLE_QUOTE:en,CHAR_NO_BREAK_SPACE:tn,CHAR_ZERO_WIDTH_NOBREAK_SPACE:rn}=$t(),nn=(e,r={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let t=r||{},n=typeof t.maxLength=="number"?Math.min(Tt,t.maxLength):Tt;if(e.length>n)throw new SyntaxError(`Input length (${e.length}), exceeds max characters (${n})`);let s={type:"root",input:e,nodes:[]},i=[s],a=s,c=s,p=0,m=e.length,h=0,R=0,f,$={},_=()=>e[h++],y=E=>{if(E.type==="text"&&c.type==="dot"&&(c.type="text"),c&&c.type==="text"&&E.type==="text"){c.value+=E.value;return}return a.nodes.push(E),E.parent=a,E.prev=c,c=E,E};for(y({type:"bos"});h0){if(a.ranges>0){a.ranges=0;let E=a.nodes.shift();a.nodes=[E,{type:"text",value:jr(a)}]}y({type:"comma",value:f}),a.commas++;continue}if(f===Xr&&R>0&&a.commas===0){let E=a.nodes;if(R===0||E.length===0){y({type:"text",value:f});continue}if(c.type==="dot"){if(a.range=[],c.value+=f,c.type="range",a.nodes.length!==3&&a.nodes.length!==5){a.invalid=!0,a.ranges=0,c.type="text";continue}a.ranges++,a.args=[];continue}if(c.type==="range"){E.pop();let S=E[E.length-1];S.value+=c.value+f,c=S,a.ranges--;continue}y({type:"dot",value:f});continue}y({type:"text",value:f})}do if(a=i.pop(),a.type!=="root"){a.nodes.forEach(T=>{T.nodes||(T.type==="open"&&(T.isOpen=!0),T.type==="close"&&(T.isClose=!0),T.nodes||(T.type="text"),T.invalid=!0)});let E=i[i.length-1],S=E.nodes.indexOf(a);E.nodes.splice(S,1,...a.nodes)}while(i.length>0);return y({type:"eos"}),s};Ot.exports=nn});var Pt=q((as,Bt)=>{"use strict";var It=He(),sn=Ct(),an=vt(),on=Nt(),Z=(e,r={})=>{let t=[];if(Array.isArray(e))for(let n of e){let s=Z.create(n,r);Array.isArray(s)?t.push(...s):t.push(s)}else t=[].concat(Z.create(e,r));return r&&r.expand===!0&&r.nodupes===!0&&(t=[...new Set(t)]),t};Z.parse=(e,r={})=>on(e,r);Z.stringify=(e,r={})=>It(typeof e=="string"?Z.parse(e,r):e,r);Z.compile=(e,r={})=>(typeof e=="string"&&(e=Z.parse(e,r)),sn(e,r));Z.expand=(e,r={})=>{typeof e=="string"&&(e=Z.parse(e,r));let t=an(e,r);return r.noempty===!0&&(t=t.filter(Boolean)),r.nodupes===!0&&(t=[...new Set(t)]),t};Z.create=(e,r={})=>e===""||e.length<3?[e]:r.expand!==!0?Z.compile(e,r):Z.expand(e,r);Bt.exports=Z});var me=q((is,qt)=>{"use strict";var un=W("path"),se="\\\\/",Mt=`[^${se}]`,ie="\\.",cn="\\+",ln="\\?",Te="\\/",fn="(?=.)",Dt="[^/]",qe=`(?:${Te}|$)`,Ut=`(?:^|${Te})`,Ke=`${ie}{1,2}${qe}`,pn=`(?!${ie})`,hn=`(?!${Ut}${Ke})`,dn=`(?!${ie}{0,1}${qe})`,gn=`(?!${Ke})`,An=`[^.${Te}]`,mn=`${Dt}*?`,Gt={DOT_LITERAL:ie,PLUS_LITERAL:cn,QMARK_LITERAL:ln,SLASH_LITERAL:Te,ONE_CHAR:fn,QMARK:Dt,END_ANCHOR:qe,DOTS_SLASH:Ke,NO_DOT:pn,NO_DOTS:hn,NO_DOT_SLASH:dn,NO_DOTS_SLASH:gn,QMARK_NO_DOT:An,STAR:mn,START_ANCHOR:Ut},Rn={...Gt,SLASH_LITERAL:`[${se}]`,QMARK:Mt,STAR:`${Mt}*?`,DOTS_SLASH:`${ie}{1,2}(?:[${se}]|$)`,NO_DOT:`(?!${ie})`,NO_DOTS:`(?!(?:^|[${se}])${ie}{1,2}(?:[${se}]|$))`,NO_DOT_SLASH:`(?!${ie}{0,1}(?:[${se}]|$))`,NO_DOTS_SLASH:`(?!${ie}{1,2}(?:[${se}]|$))`,QMARK_NO_DOT:`[^.${se}]`,START_ANCHOR:`(?:^|[${se}])`,END_ANCHOR:`(?:[${se}]|$)`},yn={alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};qt.exports={MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:yn,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:un.sep,extglobChars(e){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${e.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(e){return e===!0?Rn:Gt}}});var Re=q(Q=>{"use strict";var _n=W("path"),En=process.platform==="win32",{REGEX_BACKSLASH:bn,REGEX_REMOVE_BACKSLASH:xn,REGEX_SPECIAL_CHARS:Cn,REGEX_SPECIAL_CHARS_GLOBAL:wn}=me();Q.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);Q.hasRegexChars=e=>Cn.test(e);Q.isRegexChar=e=>e.length===1&&Q.hasRegexChars(e);Q.escapeRegex=e=>e.replace(wn,"\\$1");Q.toPosixSlashes=e=>e.replace(bn,"/");Q.removeBackslashes=e=>e.replace(xn,r=>r==="\\"?"":r);Q.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};Q.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:En===!0||_n.sep==="\\";Q.escapeLast=(e,r,t)=>{let n=e.lastIndexOf(r,t);return n===-1?e:e[n-1]==="\\"?Q.escapeLast(e,r,n-1):`${e.slice(0,n)}\\${e.slice(n)}`};Q.removePrefix=(e,r={})=>{let t=e;return t.startsWith("./")&&(t=t.slice(2),r.prefix="./"),t};Q.wrapOutput=(e,r={},t={})=>{let n=t.contains?"":"^",s=t.contains?"":"$",i=`${n}(?:${e})${s}`;return r.negated===!0&&(i=`(?:^(?!${i}).*$)`),i}});var Yt=q((us,Zt)=>{"use strict";var Kt=Re(),{CHAR_ASTERISK:We,CHAR_AT:Sn,CHAR_BACKWARD_SLASH:ye,CHAR_COMMA:vn,CHAR_DOT:je,CHAR_EXCLAMATION_MARK:Fe,CHAR_FORWARD_SLASH:Xt,CHAR_LEFT_CURLY_BRACE:Qe,CHAR_LEFT_PARENTHESES:Xe,CHAR_LEFT_SQUARE_BRACKET:Hn,CHAR_PLUS:$n,CHAR_QUESTION_MARK:Wt,CHAR_RIGHT_CURLY_BRACE:Tn,CHAR_RIGHT_PARENTHESES:jt,CHAR_RIGHT_SQUARE_BRACKET:kn}=me(),Ft=e=>e===Xt||e===ye,Qt=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},Ln=(e,r)=>{let t=r||{},n=e.length-1,s=t.parts===!0||t.scanToEnd===!0,i=[],a=[],c=[],p=e,m=-1,h=0,R=0,f=!1,$=!1,_=!1,y=!1,E=!1,S=!1,T=!1,L=!1,z=!1,I=!1,re=0,K,g,v={value:"",depth:0,isGlob:!1},k=()=>m>=n,l=()=>p.charCodeAt(m+1),H=()=>(K=g,p.charCodeAt(++m));for(;m0&&(B=p.slice(0,h),p=p.slice(h),R-=h),w&&_===!0&&R>0?(w=p.slice(0,R),o=p.slice(R)):_===!0?(w="",o=p):w=p,w&&w!==""&&w!=="/"&&w!==p&&Ft(w.charCodeAt(w.length-1))&&(w=w.slice(0,-1)),t.unescape===!0&&(o&&(o=Kt.removeBackslashes(o)),w&&T===!0&&(w=Kt.removeBackslashes(w)));let u={prefix:B,input:e,start:h,base:w,glob:o,isBrace:f,isBracket:$,isGlob:_,isExtglob:y,isGlobstar:E,negated:L,negatedExtglob:z};if(t.tokens===!0&&(u.maxDepth=0,Ft(g)||a.push(v),u.tokens=a),t.parts===!0||t.tokens===!0){let P;for(let b=0;b{"use strict";var ke=me(),Y=Re(),{MAX_LENGTH:Le,POSIX_REGEX_SOURCE:On,REGEX_NON_SPECIAL_CHARS:Nn,REGEX_SPECIAL_CHARS_BACKREF:In,REPLACEMENTS:zt}=ke,Bn=(e,r)=>{if(typeof r.expandRange=="function")return r.expandRange(...e,r);e.sort();let t=`[${e.join("-")}]`;try{new RegExp(t)}catch{return e.map(s=>Y.escapeRegex(s)).join("..")}return t},de=(e,r)=>`Missing ${e}: "${r}" - use "\\\\${r}" to match literal characters`,Vt=(e,r)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=zt[e]||e;let t={...r},n=typeof t.maxLength=="number"?Math.min(Le,t.maxLength):Le,s=e.length;if(s>n)throw new SyntaxError(`Input length: ${s}, exceeds maximum allowed length: ${n}`);let i={type:"bos",value:"",output:t.prepend||""},a=[i],c=t.capture?"":"?:",p=Y.isWindows(r),m=ke.globChars(p),h=ke.extglobChars(m),{DOT_LITERAL:R,PLUS_LITERAL:f,SLASH_LITERAL:$,ONE_CHAR:_,DOTS_SLASH:y,NO_DOT:E,NO_DOT_SLASH:S,NO_DOTS_SLASH:T,QMARK:L,QMARK_NO_DOT:z,STAR:I,START_ANCHOR:re}=m,K=A=>`(${c}(?:(?!${re}${A.dot?y:R}).)*?)`,g=t.dot?"":E,v=t.dot?L:z,k=t.bash===!0?K(t):I;t.capture&&(k=`(${k})`),typeof t.noext=="boolean"&&(t.noextglob=t.noext);let l={input:e,index:-1,start:0,dot:t.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:a};e=Y.removePrefix(e,l),s=e.length;let H=[],w=[],B=[],o=i,u,P=()=>l.index===s-1,b=l.peek=(A=1)=>e[l.index+A],V=l.advance=()=>e[++l.index]||"",J=()=>e.slice(l.index+1),X=(A="",O=0)=>{l.consumed+=A,l.index+=O},Ee=A=>{l.output+=A.output!=null?A.output:A.value,X(A.value)},mr=()=>{let A=1;for(;b()==="!"&&(b(2)!=="("||b(3)==="?");)V(),l.start++,A++;return A%2===0?!1:(l.negated=!0,l.start++,!0)},be=A=>{l[A]++,B.push(A)},oe=A=>{l[A]--,B.pop()},C=A=>{if(o.type==="globstar"){let O=l.braces>0&&(A.type==="comma"||A.type==="brace"),d=A.extglob===!0||H.length&&(A.type==="pipe"||A.type==="paren");A.type!=="slash"&&A.type!=="paren"&&!O&&!d&&(l.output=l.output.slice(0,-o.output.length),o.type="star",o.value="*",o.output=k,l.output+=o.output)}if(H.length&&A.type!=="paren"&&(H[H.length-1].inner+=A.value),(A.value||A.output)&&Ee(A),o&&o.type==="text"&&A.type==="text"){o.value+=A.value,o.output=(o.output||"")+A.value;return}A.prev=o,a.push(A),o=A},xe=(A,O)=>{let d={...h[O],conditions:1,inner:""};d.prev=o,d.parens=l.parens,d.output=l.output;let x=(t.capture?"(":"")+d.open;be("parens"),C({type:A,value:O,output:l.output?"":_}),C({type:"paren",extglob:!0,value:V(),output:x}),H.push(d)},Rr=A=>{let O=A.close+(t.capture?")":""),d;if(A.type==="negate"){let x=k;A.inner&&A.inner.length>1&&A.inner.includes("/")&&(x=K(t)),(x!==k||P()||/^\)+$/.test(J()))&&(O=A.close=`)$))${x}`),A.inner.includes("*")&&(d=J())&&/^\.[^\\/.]+$/.test(d)&&(O=A.close=`)${d})${x})`),A.prev.type==="bos"&&(l.negatedExtglob=!0)}C({type:"paren",extglob:!0,value:u,output:O}),oe("parens")};if(t.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let A=!1,O=e.replace(In,(d,x,M,j,G,Ie)=>j==="\\"?(A=!0,d):j==="?"?x?x+j+(G?L.repeat(G.length):""):Ie===0?v+(G?L.repeat(G.length):""):L.repeat(M.length):j==="."?R.repeat(M.length):j==="*"?x?x+j+(G?k:""):k:x?d:`\\${d}`);return A===!0&&(t.unescape===!0?O=O.replace(/\\/g,""):O=O.replace(/\\+/g,d=>d.length%2===0?"\\\\":d?"\\":"")),O===e&&t.contains===!0?(l.output=e,l):(l.output=Y.wrapOutput(O,l,r),l)}for(;!P();){if(u=V(),u==="\0")continue;if(u==="\\"){let d=b();if(d==="/"&&t.bash!==!0||d==="."||d===";")continue;if(!d){u+="\\",C({type:"text",value:u});continue}let x=/^\\+/.exec(J()),M=0;if(x&&x[0].length>2&&(M=x[0].length,l.index+=M,M%2!==0&&(u+="\\")),t.unescape===!0?u=V():u+=V(),l.brackets===0){C({type:"text",value:u});continue}}if(l.brackets>0&&(u!=="]"||o.value==="["||o.value==="[^")){if(t.posix!==!1&&u===":"){let d=o.value.slice(1);if(d.includes("[")&&(o.posix=!0,d.includes(":"))){let x=o.value.lastIndexOf("["),M=o.value.slice(0,x),j=o.value.slice(x+2),G=On[j];if(G){o.value=M+G,l.backtrack=!0,V(),!i.output&&a.indexOf(o)===1&&(i.output=_);continue}}}(u==="["&&b()!==":"||u==="-"&&b()==="]")&&(u=`\\${u}`),u==="]"&&(o.value==="["||o.value==="[^")&&(u=`\\${u}`),t.posix===!0&&u==="!"&&o.value==="["&&(u="^"),o.value+=u,Ee({value:u});continue}if(l.quotes===1&&u!=='"'){u=Y.escapeRegex(u),o.value+=u,Ee({value:u});continue}if(u==='"'){l.quotes=l.quotes===1?0:1,t.keepQuotes===!0&&C({type:"text",value:u});continue}if(u==="("){be("parens"),C({type:"paren",value:u});continue}if(u===")"){if(l.parens===0&&t.strictBrackets===!0)throw new SyntaxError(de("opening","("));let d=H[H.length-1];if(d&&l.parens===d.parens+1){Rr(H.pop());continue}C({type:"paren",value:u,output:l.parens?")":"\\)"}),oe("parens");continue}if(u==="["){if(t.nobracket===!0||!J().includes("]")){if(t.nobracket!==!0&&t.strictBrackets===!0)throw new SyntaxError(de("closing","]"));u=`\\${u}`}else be("brackets");C({type:"bracket",value:u});continue}if(u==="]"){if(t.nobracket===!0||o&&o.type==="bracket"&&o.value.length===1){C({type:"text",value:u,output:`\\${u}`});continue}if(l.brackets===0){if(t.strictBrackets===!0)throw new SyntaxError(de("opening","["));C({type:"text",value:u,output:`\\${u}`});continue}oe("brackets");let d=o.value.slice(1);if(o.posix!==!0&&d[0]==="^"&&!d.includes("/")&&(u=`/${u}`),o.value+=u,Ee({value:u}),t.literalBrackets===!1||Y.hasRegexChars(d))continue;let x=Y.escapeRegex(o.value);if(l.output=l.output.slice(0,-o.value.length),t.literalBrackets===!0){l.output+=x,o.value=x;continue}o.value=`(${c}${x}|${o.value})`,l.output+=o.value;continue}if(u==="{"&&t.nobrace!==!0){be("braces");let d={type:"brace",value:u,output:"(",outputIndex:l.output.length,tokensIndex:l.tokens.length};w.push(d),C(d);continue}if(u==="}"){let d=w[w.length-1];if(t.nobrace===!0||!d){C({type:"text",value:u,output:u});continue}let x=")";if(d.dots===!0){let M=a.slice(),j=[];for(let G=M.length-1;G>=0&&(a.pop(),M[G].type!=="brace");G--)M[G].type!=="dots"&&j.unshift(M[G].value);x=Bn(j,t),l.backtrack=!0}if(d.comma!==!0&&d.dots!==!0){let M=l.output.slice(0,d.outputIndex),j=l.tokens.slice(d.tokensIndex);d.value=d.output="\\{",u=x="\\}",l.output=M;for(let G of j)l.output+=G.output||G.value}C({type:"brace",value:u,output:x}),oe("braces"),w.pop();continue}if(u==="|"){H.length>0&&H[H.length-1].conditions++,C({type:"text",value:u});continue}if(u===","){let d=u,x=w[w.length-1];x&&B[B.length-1]==="braces"&&(x.comma=!0,d="|"),C({type:"comma",value:u,output:d});continue}if(u==="/"){if(o.type==="dot"&&l.index===l.start+1){l.start=l.index+1,l.consumed="",l.output="",a.pop(),o=i;continue}C({type:"slash",value:u,output:$});continue}if(u==="."){if(l.braces>0&&o.type==="dot"){o.value==="."&&(o.output=R);let d=w[w.length-1];o.type="dots",o.output+=u,o.value+=u,d.dots=!0;continue}if(l.braces+l.parens===0&&o.type!=="bos"&&o.type!=="slash"){C({type:"text",value:u,output:R});continue}C({type:"dot",value:u,output:R});continue}if(u==="?"){if(!(o&&o.value==="(")&&t.noextglob!==!0&&b()==="("&&b(2)!=="?"){xe("qmark",u);continue}if(o&&o.type==="paren"){let x=b(),M=u;if(x==="<"&&!Y.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(o.value==="("&&!/[!=<:]/.test(x)||x==="<"&&!/<([!=]|\w+>)/.test(J()))&&(M=`\\${u}`),C({type:"text",value:u,output:M});continue}if(t.dot!==!0&&(o.type==="slash"||o.type==="bos")){C({type:"qmark",value:u,output:z});continue}C({type:"qmark",value:u,output:L});continue}if(u==="!"){if(t.noextglob!==!0&&b()==="("&&(b(2)!=="?"||!/[!=<:]/.test(b(3)))){xe("negate",u);continue}if(t.nonegate!==!0&&l.index===0){mr();continue}}if(u==="+"){if(t.noextglob!==!0&&b()==="("&&b(2)!=="?"){xe("plus",u);continue}if(o&&o.value==="("||t.regex===!1){C({type:"plus",value:u,output:f});continue}if(o&&(o.type==="bracket"||o.type==="paren"||o.type==="brace")||l.parens>0){C({type:"plus",value:u});continue}C({type:"plus",value:f});continue}if(u==="@"){if(t.noextglob!==!0&&b()==="("&&b(2)!=="?"){C({type:"at",extglob:!0,value:u,output:""});continue}C({type:"text",value:u});continue}if(u!=="*"){(u==="$"||u==="^")&&(u=`\\${u}`);let d=Nn.exec(J());d&&(u+=d[0],l.index+=d[0].length),C({type:"text",value:u});continue}if(o&&(o.type==="globstar"||o.star===!0)){o.type="star",o.star=!0,o.value+=u,o.output=k,l.backtrack=!0,l.globstar=!0,X(u);continue}let A=J();if(t.noextglob!==!0&&/^\([^?]/.test(A)){xe("star",u);continue}if(o.type==="star"){if(t.noglobstar===!0){X(u);continue}let d=o.prev,x=d.prev,M=d.type==="slash"||d.type==="bos",j=x&&(x.type==="star"||x.type==="globstar");if(t.bash===!0&&(!M||A[0]&&A[0]!=="/")){C({type:"star",value:u,output:""});continue}let G=l.braces>0&&(d.type==="comma"||d.type==="brace"),Ie=H.length&&(d.type==="pipe"||d.type==="paren");if(!M&&d.type!=="paren"&&!G&&!Ie){C({type:"star",value:u,output:""});continue}for(;A.slice(0,3)==="/**";){let Ce=e[l.index+4];if(Ce&&Ce!=="/")break;A=A.slice(3),X("/**",3)}if(d.type==="bos"&&P()){o.type="globstar",o.value+=u,o.output=K(t),l.output=o.output,l.globstar=!0,X(u);continue}if(d.type==="slash"&&d.prev.type!=="bos"&&!j&&P()){l.output=l.output.slice(0,-(d.output+o.output).length),d.output=`(?:${d.output}`,o.type="globstar",o.output=K(t)+(t.strictSlashes?")":"|$)"),o.value+=u,l.globstar=!0,l.output+=d.output+o.output,X(u);continue}if(d.type==="slash"&&d.prev.type!=="bos"&&A[0]==="/"){let Ce=A[1]!==void 0?"|$":"";l.output=l.output.slice(0,-(d.output+o.output).length),d.output=`(?:${d.output}`,o.type="globstar",o.output=`${K(t)}${$}|${$}${Ce})`,o.value+=u,l.output+=d.output+o.output,l.globstar=!0,X(u+V()),C({type:"slash",value:"/",output:""});continue}if(d.type==="bos"&&A[0]==="/"){o.type="globstar",o.value+=u,o.output=`(?:^|${$}|${K(t)}${$})`,l.output=o.output,l.globstar=!0,X(u+V()),C({type:"slash",value:"/",output:""});continue}l.output=l.output.slice(0,-o.output.length),o.type="globstar",o.output=K(t),o.value+=u,l.output+=o.output,l.globstar=!0,X(u);continue}let O={type:"star",value:u,output:k};if(t.bash===!0){O.output=".*?",(o.type==="bos"||o.type==="slash")&&(O.output=g+O.output),C(O);continue}if(o&&(o.type==="bracket"||o.type==="paren")&&t.regex===!0){O.output=u,C(O);continue}(l.index===l.start||o.type==="slash"||o.type==="dot")&&(o.type==="dot"?(l.output+=S,o.output+=S):t.dot===!0?(l.output+=T,o.output+=T):(l.output+=g,o.output+=g),b()!=="*"&&(l.output+=_,o.output+=_)),C(O)}for(;l.brackets>0;){if(t.strictBrackets===!0)throw new SyntaxError(de("closing","]"));l.output=Y.escapeLast(l.output,"["),oe("brackets")}for(;l.parens>0;){if(t.strictBrackets===!0)throw new SyntaxError(de("closing",")"));l.output=Y.escapeLast(l.output,"("),oe("parens")}for(;l.braces>0;){if(t.strictBrackets===!0)throw new SyntaxError(de("closing","}"));l.output=Y.escapeLast(l.output,"{"),oe("braces")}if(t.strictSlashes!==!0&&(o.type==="star"||o.type==="bracket")&&C({type:"maybe_slash",value:"",output:`${$}?`}),l.backtrack===!0){l.output="";for(let A of l.tokens)l.output+=A.output!=null?A.output:A.value,A.suffix&&(l.output+=A.suffix)}return l};Vt.fastpaths=(e,r)=>{let t={...r},n=typeof t.maxLength=="number"?Math.min(Le,t.maxLength):Le,s=e.length;if(s>n)throw new SyntaxError(`Input length: ${s}, exceeds maximum allowed length: ${n}`);e=zt[e]||e;let i=Y.isWindows(r),{DOT_LITERAL:a,SLASH_LITERAL:c,ONE_CHAR:p,DOTS_SLASH:m,NO_DOT:h,NO_DOTS:R,NO_DOTS_SLASH:f,STAR:$,START_ANCHOR:_}=ke.globChars(i),y=t.dot?R:h,E=t.dot?f:h,S=t.capture?"":"?:",T={negated:!1,prefix:""},L=t.bash===!0?".*?":$;t.capture&&(L=`(${L})`);let z=g=>g.noglobstar===!0?L:`(${S}(?:(?!${_}${g.dot?m:a}).)*?)`,I=g=>{switch(g){case"*":return`${y}${p}${L}`;case".*":return`${a}${p}${L}`;case"*.*":return`${y}${L}${a}${p}${L}`;case"*/*":return`${y}${L}${c}${p}${E}${L}`;case"**":return y+z(t);case"**/*":return`(?:${y}${z(t)}${c})?${E}${p}${L}`;case"**/*.*":return`(?:${y}${z(t)}${c})?${E}${L}${a}${p}${L}`;case"**/.*":return`(?:${y}${z(t)}${c})?${a}${p}${L}`;default:{let v=/^(.*?)\.(\w+)$/.exec(g);if(!v)return;let k=I(v[1]);return k?k+a+v[2]:void 0}}},re=Y.removePrefix(e,T),K=I(re);return K&&t.strictSlashes!==!0&&(K+=`${c}?`),K};Jt.exports=Vt});var rr=q((ls,tr)=>{"use strict";var Pn=W("path"),Mn=Yt(),Ze=er(),Ye=Re(),Dn=me(),Un=e=>e&&typeof e=="object"&&!Array.isArray(e),D=(e,r,t=!1)=>{if(Array.isArray(e)){let h=e.map(f=>D(f,r,t));return f=>{for(let $ of h){let _=$(f);if(_)return _}return!1}}let n=Un(e)&&e.tokens&&e.input;if(e===""||typeof e!="string"&&!n)throw new TypeError("Expected pattern to be a non-empty string");let s=r||{},i=Ye.isWindows(r),a=n?D.compileRe(e,r):D.makeRe(e,r,!1,!0),c=a.state;delete a.state;let p=()=>!1;if(s.ignore){let h={...r,ignore:null,onMatch:null,onResult:null};p=D(s.ignore,h,t)}let m=(h,R=!1)=>{let{isMatch:f,match:$,output:_}=D.test(h,a,r,{glob:e,posix:i}),y={glob:e,state:c,regex:a,posix:i,input:h,output:_,match:$,isMatch:f};return typeof s.onResult=="function"&&s.onResult(y),f===!1?(y.isMatch=!1,R?y:!1):p(h)?(typeof s.onIgnore=="function"&&s.onIgnore(y),y.isMatch=!1,R?y:!1):(typeof s.onMatch=="function"&&s.onMatch(y),R?y:!0)};return t&&(m.state=c),m};D.test=(e,r,t,{glob:n,posix:s}={})=>{if(typeof e!="string")throw new TypeError("Expected input to be a string");if(e==="")return{isMatch:!1,output:""};let i=t||{},a=i.format||(s?Ye.toPosixSlashes:null),c=e===n,p=c&&a?a(e):e;return c===!1&&(p=a?a(e):e,c=p===n),(c===!1||i.capture===!0)&&(i.matchBase===!0||i.basename===!0?c=D.matchBase(e,r,t,s):c=r.exec(p)),{isMatch:Boolean(c),match:c,output:p}};D.matchBase=(e,r,t,n=Ye.isWindows(t))=>(r instanceof RegExp?r:D.makeRe(r,t)).test(Pn.basename(e));D.isMatch=(e,r,t)=>D(r,t)(e);D.parse=(e,r)=>Array.isArray(e)?e.map(t=>D.parse(t,r)):Ze(e,{...r,fastpaths:!1});D.scan=(e,r)=>Mn(e,r);D.compileRe=(e,r,t=!1,n=!1)=>{if(t===!0)return e.output;let s=r||{},i=s.contains?"":"^",a=s.contains?"":"$",c=`${i}(?:${e.output})${a}`;e&&e.negated===!0&&(c=`^(?!${c}).*$`);let p=D.toRegex(c,r);return n===!0&&(p.state=e),p};D.makeRe=(e,r={},t=!1,n=!1)=>{if(!e||typeof e!="string")throw new TypeError("Expected a non-empty string");let s={negated:!1,fastpaths:!0};return r.fastpaths!==!1&&(e[0]==="."||e[0]==="*")&&(s.output=Ze.fastpaths(e,r)),s.output||(s=Ze(e,r)),D.compileRe(s,r,t,n)};D.toRegex=(e,r)=>{try{let t=r||{};return new RegExp(e,t.flags||(t.nocase?"i":""))}catch(t){if(r&&r.debug===!0)throw t;return/$^/}};D.constants=Dn;tr.exports=D});var sr=q((fs,nr)=>{"use strict";nr.exports=rr()});var cr=q((ps,ur)=>{"use strict";var ir=W("util"),or=Pt(),ae=sr(),ze=Re(),ar=e=>e===""||e==="./",N=(e,r,t)=>{r=[].concat(r),e=[].concat(e);let n=new Set,s=new Set,i=new Set,a=0,c=h=>{i.add(h.output),t&&t.onResult&&t.onResult(h)};for(let h=0;h!n.has(h));if(t&&m.length===0){if(t.failglob===!0)throw new Error(`No matches found for "${r.join(", ")}"`);if(t.nonull===!0||t.nullglob===!0)return t.unescape?r.map(h=>h.replace(/\\/g,"")):r}return m};N.match=N;N.matcher=(e,r)=>ae(e,r);N.isMatch=(e,r,t)=>ae(r,t)(e);N.any=N.isMatch;N.not=(e,r,t={})=>{r=[].concat(r).map(String);let n=new Set,s=[],a=N(e,r,{...t,onResult:c=>{t.onResult&&t.onResult(c),s.push(c.output)}});for(let c of s)a.includes(c)||n.add(c);return[...n]};N.contains=(e,r,t)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${ir.inspect(e)}"`);if(Array.isArray(r))return r.some(n=>N.contains(e,n,t));if(typeof r=="string"){if(ar(e)||ar(r))return!1;if(e.includes(r)||e.startsWith("./")&&e.slice(2).includes(r))return!0}return N.isMatch(e,r,{...t,contains:!0})};N.matchKeys=(e,r,t)=>{if(!ze.isObject(e))throw new TypeError("Expected the first argument to be an object");let n=N(Object.keys(e),r,t),s={};for(let i of n)s[i]=e[i];return s};N.some=(e,r,t)=>{let n=[].concat(e);for(let s of[].concat(r)){let i=ae(String(s),t);if(n.some(a=>i(a)))return!0}return!1};N.every=(e,r,t)=>{let n=[].concat(e);for(let s of[].concat(r)){let i=ae(String(s),t);if(!n.every(a=>i(a)))return!1}return!0};N.all=(e,r,t)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${ir.inspect(e)}"`);return[].concat(r).every(n=>ae(n,t)(e))};N.capture=(e,r,t)=>{let n=ze.isWindows(t),i=ae.makeRe(String(e),{...t,capture:!0}).exec(n?ze.toPosixSlashes(r):r);if(i)return i.slice(1).map(a=>a===void 0?"":a)};N.makeRe=(...e)=>ae.makeRe(...e);N.scan=(...e)=>ae.scan(...e);N.parse=(e,r)=>{let t=[];for(let n of[].concat(e||[]))for(let s of or(String(n),r))t.push(ae.parse(s,r));return t};N.braces=(e,r)=>{if(typeof e!="string")throw new TypeError("Expected a string");return r&&r.nobrace===!0||!/\{.*\}/.test(e)?[e]:or(e,r)};N.braceExpand=(e,r)=>{if(typeof e!="string")throw new TypeError("Expected a string");return N.braces(e,{...r,expand:!0})};ur.exports=N});var fr=q((hs,lr)=>{"use strict";lr.exports=(e,...r)=>new Promise(t=>{t(e(...r))})});var hr=q((ds,Ve)=>{"use strict";var Gn=fr(),pr=e=>{if(e<1)throw new TypeError("Expected `concurrency` to be a number from 1 and up");let r=[],t=0,n=()=>{t--,r.length>0&&r.shift()()},s=(c,p,...m)=>{t++;let h=Gn(c,...m);p(h),h.then(n,n)},i=(c,p,...m)=>{tnew Promise(m=>i(c,m,...p));return Object.defineProperties(a,{activeCount:{get:()=>t},pendingCount:{get:()=>r.length}}),a};Ve.exports=pr;Ve.exports.default=pr});var jn={};Cr(jn,{default:()=>Wn});var Se=W("@yarnpkg/cli"),ne=W("@yarnpkg/core"),et=W("@yarnpkg/core"),ue=W("clipanion"),ce=class extends Se.BaseCommand{constructor(){super(...arguments);this.json=ue.Option.Boolean("--json",!1,{description:"Format the output as an NDJSON stream"});this.production=ue.Option.Boolean("--production",!1,{description:"Only install regular dependencies by omitting dev dependencies"});this.all=ue.Option.Boolean("-A,--all",!1,{description:"Install the entire project"});this.workspaces=ue.Option.Rest()}async execute(){let t=await ne.Configuration.find(this.context.cwd,this.context.plugins),{project:n,workspace:s}=await ne.Project.find(t,this.context.cwd),i=await ne.Cache.find(t);await n.restoreInstallState({restoreResolutions:!1});let a;if(this.all)a=new Set(n.workspaces);else if(this.workspaces.length===0){if(!s)throw new Se.WorkspaceRequiredError(n.cwd,this.context.cwd);a=new Set([s])}else a=new Set(this.workspaces.map(p=>n.getWorkspaceByIdent(et.structUtils.parseIdent(p))));for(let p of a)for(let m of this.production?["dependencies"]:ne.Manifest.hardDependencies)for(let h of p.manifest.getForScope(m).values()){let R=n.tryWorkspaceByDescriptor(h);R!==null&&a.add(R)}for(let p of n.workspaces)a.has(p)?this.production&&p.manifest.devDependencies.clear():(p.manifest.installConfig=p.manifest.installConfig||{},p.manifest.installConfig.selfReferences=!1,p.manifest.dependencies.clear(),p.manifest.devDependencies.clear(),p.manifest.peerDependencies.clear(),p.manifest.scripts.clear());return(await ne.StreamReport.start({configuration:t,json:this.json,stdout:this.context.stdout,includeLogs:!0},async p=>{await n.install({cache:i,report:p,persistProject:!1})})).exitCode()}};ce.paths=[["workspaces","focus"]],ce.usage=ue.Command.Usage({category:"Workspace-related commands",description:"install a single workspace and its dependencies",details:"\n This command will run an install as if the specified workspaces (and all other workspaces they depend on) were the only ones in the project. If no workspaces are explicitly listed, the active one will be assumed.\n\n Note that this command is only very moderately useful when using zero-installs, since the cache will contain all the packages anyway - meaning that the only difference between a full install and a focused install would just be a few extra lines in the `.pnp.cjs` file, at the cost of introducing an extra complexity.\n\n If the `-A,--all` flag is set, the entire project will be installed. Combine with `--production` to replicate the old `yarn install --production`.\n "});var Ne=W("@yarnpkg/cli"),ge=W("@yarnpkg/core"),_e=W("@yarnpkg/core"),F=W("@yarnpkg/core"),gr=W("@yarnpkg/plugin-git"),U=W("clipanion"),Oe=Be(cr()),Ar=Be(hr()),te=Be(W("typanion")),pe=class extends Ne.BaseCommand{constructor(){super(...arguments);this.recursive=U.Option.Boolean("-R,--recursive",!1,{description:"Find packages via dependencies/devDependencies instead of using the workspaces field"});this.from=U.Option.Array("--from",[],{description:"An array of glob pattern idents from which to base any recursion"});this.all=U.Option.Boolean("-A,--all",!1,{description:"Run the command on all workspaces of a project"});this.verbose=U.Option.Boolean("-v,--verbose",!1,{description:"Prefix each output line with the name of the originating workspace"});this.parallel=U.Option.Boolean("-p,--parallel",!1,{description:"Run the commands in parallel"});this.interlaced=U.Option.Boolean("-i,--interlaced",!1,{description:"Print the output of commands in real-time instead of buffering it"});this.jobs=U.Option.String("-j,--jobs",{description:"The maximum number of parallel tasks that the execution will be limited to; or `unlimited`",validator:te.isOneOf([te.isEnum(["unlimited"]),te.applyCascade(te.isNumber(),[te.isInteger(),te.isAtLeast(1)])])});this.topological=U.Option.Boolean("-t,--topological",!1,{description:"Run the command after all workspaces it depends on (regular) have finished"});this.topologicalDev=U.Option.Boolean("--topological-dev",!1,{description:"Run the command after all workspaces it depends on (regular + dev) have finished"});this.include=U.Option.Array("--include",[],{description:"An array of glob pattern idents; only matching workspaces will be traversed"});this.exclude=U.Option.Array("--exclude",[],{description:"An array of glob pattern idents; matching workspaces won't be traversed"});this.publicOnly=U.Option.Boolean("--no-private",{description:"Avoid running the command on private workspaces"});this.since=U.Option.String("--since",{description:"Only include workspaces that have been changed since the specified ref.",tolerateBoolean:!0});this.commandName=U.Option.String();this.args=U.Option.Proxy()}async execute(){let t=await ge.Configuration.find(this.context.cwd,this.context.plugins),{project:n,workspace:s}=await ge.Project.find(t,this.context.cwd);if(!this.all&&!s)throw new Ne.WorkspaceRequiredError(n.cwd,this.context.cwd);await n.restoreInstallState();let i=this.cli.process([this.commandName,...this.args]),a=i.path.length===1&&i.path[0]==="run"&&typeof i.scriptName<"u"?i.scriptName:null;if(i.path.length===0)throw new U.UsageError("Invalid subcommand name for iteration - use the 'run' keyword if you wish to execute a script");let c=this.all?n.topLevelWorkspace:s,p=this.since?Array.from(await gr.gitUtils.fetchChangedWorkspaces({ref:this.since,project:n})):[c,...this.from.length>0?c.getRecursiveWorkspaceChildren():[]],m=g=>Oe.default.isMatch(F.structUtils.stringifyIdent(g.locator),this.from),h=this.from.length>0?p.filter(m):p,R=new Set([...h,...h.map(g=>[...this.recursive?this.since?g.getRecursiveWorkspaceDependents():g.getRecursiveWorkspaceDependencies():g.getRecursiveWorkspaceChildren()]).flat()]),f=[],$=!1;if(a!=null&&a.includes(":")){for(let g of n.workspaces)if(g.manifest.scripts.has(a)&&($=!$,$===!1))break}for(let g of R)a&&!g.manifest.scripts.has(a)&&!$&&!(await ge.scriptUtils.getWorkspaceAccessibleBinaries(g)).has(a)||a===process.env.npm_lifecycle_event&&g.cwd===s.cwd||this.include.length>0&&!Oe.default.isMatch(F.structUtils.stringifyIdent(g.locator),this.include)||this.exclude.length>0&&Oe.default.isMatch(F.structUtils.stringifyIdent(g.locator),this.exclude)||this.publicOnly&&g.manifest.private===!0||f.push(g);let _=this.parallel?this.jobs==="unlimited"?1/0:Number(this.jobs)||Math.ceil(F.nodeUtils.availableParallelism()/2):1,y=_===1?!1:this.parallel,E=y?this.interlaced:!0,S=(0,Ar.default)(_),T=new Map,L=new Set,z=0,I=null,re=!1,K=await _e.StreamReport.start({configuration:t,stdout:this.context.stdout,includePrefix:!1},async g=>{let v=async(k,{commandIndex:l})=>{if(re)return-1;!y&&this.verbose&&l>1&&g.reportSeparator();let H=qn(k,{configuration:t,verbose:this.verbose,commandIndex:l}),[w,B]=dr(g,{prefix:H,interlaced:E}),[o,u]=dr(g,{prefix:H,interlaced:E});try{this.verbose&&g.reportInfo(null,`${H} Process started`);let P=Date.now(),b=await this.cli.run([this.commandName,...this.args],{cwd:k.cwd,stdout:w,stderr:o})||0;w.end(),o.end(),await B,await u;let V=Date.now();if(this.verbose){let J=t.get("enableTimers")?`, completed in ${F.formatUtils.pretty(t,V-P,F.formatUtils.Type.DURATION)}`:"";g.reportInfo(null,`${H} Process exited (exit code ${b})${J}`)}return b===130&&(re=!0,I=b),b}catch(P){throw w.end(),o.end(),await B,await u,P}};for(let k of f)T.set(k.anchoredLocator.locatorHash,k);for(;T.size>0&&!g.hasErrors();){let k=[];for(let[w,B]of T){if(L.has(B.anchoredDescriptor.descriptorHash))continue;let o=!0;if(this.topological||this.topologicalDev){let u=this.topologicalDev?new Map([...B.manifest.dependencies,...B.manifest.devDependencies]):B.manifest.dependencies;for(let P of u.values()){let b=n.tryWorkspaceByDescriptor(P);if(o=b===null||!T.has(b.anchoredLocator.locatorHash),!o)break}}if(!!o&&(L.add(B.anchoredDescriptor.descriptorHash),k.push(S(async()=>{let u=await v(B,{commandIndex:++z});return T.delete(w),L.delete(B.anchoredDescriptor.descriptorHash),u})),!y))break}if(k.length===0){let w=Array.from(T.values()).map(B=>F.structUtils.prettyLocator(t,B.anchoredLocator)).join(", ");g.reportError(_e.MessageName.CYCLIC_DEPENDENCIES,`Dependency cycle detected (${w})`);return}let H=(await Promise.all(k)).find(w=>w!==0);I===null&&(I=typeof H<"u"?1:I),(this.topological||this.topologicalDev)&&typeof H<"u"&&g.reportError(_e.MessageName.UNNAMED,"The command failed for workspaces that are depended upon by other workspaces; can't satisfy the dependency graph")}});return I!==null?I:K.exitCode()}};pe.paths=[["workspaces","foreach"]],pe.usage=U.Command.Usage({category:"Workspace-related commands",description:"run a command on all workspaces",details:"\n This command will run a given sub-command on current and all its descendant workspaces. Various flags can alter the exact behavior of the command:\n\n - If `-p,--parallel` is set, the commands will be ran in parallel; they'll by default be limited to a number of parallel tasks roughly equal to half your core number, but that can be overridden via `-j,--jobs`, or disabled by setting `-j unlimited`.\n\n - If `-p,--parallel` and `-i,--interlaced` are both set, Yarn will print the lines from the output as it receives them. If `-i,--interlaced` wasn't set, it would instead buffer the output from each process and print the resulting buffers only after their source processes have exited.\n\n - If `-t,--topological` is set, Yarn will only run the command after all workspaces that it depends on through the `dependencies` field have successfully finished executing. If `--topological-dev` is set, both the `dependencies` and `devDependencies` fields will be considered when figuring out the wait points.\n\n - If `-A,--all` is set, Yarn will run the command on all the workspaces of a project. By default yarn runs the command only on current and all its descendant workspaces.\n\n - If `-R,--recursive` is set, Yarn will find workspaces to run the command on by recursively evaluating `dependencies` and `devDependencies` fields, instead of looking at the `workspaces` fields.\n\n - If `--from` is set, Yarn will use the packages matching the 'from' glob as the starting point for any recursive search.\n\n - If `--since` is set, Yarn will only run the command on workspaces that have been modified since the specified ref. By default Yarn will use the refs specified by the `changesetBaseRefs` configuration option.\n\n - The command may apply to only some workspaces through the use of `--include` which acts as a whitelist. The `--exclude` flag will do the opposite and will be a list of packages that mustn't execute the script. Both flags accept glob patterns (if valid Idents and supported by [micromatch](https://github.com/micromatch/micromatch)). Make sure to escape the patterns, to prevent your own shell from trying to expand them.\n\n Adding the `-v,--verbose` flag will cause Yarn to print more information; in particular the name of the workspace that generated the output will be printed at the front of each line.\n\n If the command is `run` and the script being run does not exist the child workspace will be skipped without error.\n ",examples:[["Publish current and all descendant packages","yarn workspaces foreach npm publish --tolerate-republish"],["Run build script on current and all descendant packages","yarn workspaces foreach run build"],["Run build script on current and all descendant packages in parallel, building package dependencies first","yarn workspaces foreach -pt run build"],["Run build script on several packages and all their dependencies, building dependencies first","yarn workspaces foreach -ptR --from '{workspace-a,workspace-b}' run build"]]});function dr(e,{prefix:r,interlaced:t}){let n=e.createStreamReporter(r),s=new F.miscUtils.DefaultStream;s.pipe(n,{end:!1}),s.on("finish",()=>{n.end()});let i=new Promise(c=>{n.on("finish",()=>{c(s.active)})});if(t)return[s,i];let a=new F.miscUtils.BufferStream;return a.pipe(s,{end:!1}),a.on("finish",()=>{s.end()}),[a,i]}function qn(e,{configuration:r,commandIndex:t,verbose:n}){if(!n)return null;let i=`[${F.structUtils.stringifyIdent(e.locator)}]:`,a=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],c=a[t%a.length];return F.formatUtils.pretty(r,i,c)}var Kn={commands:[ce,pe]},Wn=Kn;return wr(jn);})(); 8 | /*! 9 | * fill-range 10 | * 11 | * Copyright (c) 2014-present, Jon Schlinkert. 12 | * Licensed under the MIT License. 13 | */ 14 | /*! 15 | * is-number 16 | * 17 | * Copyright (c) 2014-present, Jon Schlinkert. 18 | * Released under the MIT License. 19 | */ 20 | /*! 21 | * to-regex-range 22 | * 23 | * Copyright (c) 2015-present, Jon Schlinkert. 24 | * Released under the MIT License. 25 | */ 26 | return plugin; 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /.yarnrc.yml: -------------------------------------------------------------------------------- 1 | packageExtensions: 2 | next-contentlayer@*: 3 | peerDependencies: 4 | contentlayer: "*" 5 | 6 | plugins: 7 | - path: .yarn/plugins/@yarnpkg/plugin-version.cjs 8 | spec: "@yarnpkg/plugin-version" 9 | - path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs 10 | spec: "@yarnpkg/plugin-workspace-tools" 11 | 12 | yarnPath: .yarn/releases/yarn-3.5.1.cjs 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | ## Notion Render 5 | 6 | ### Transform [Notion](https://notion.so) Rich Text into HTML, JSX and more. 7 | 8 |
9 |
10 | 11 |
12 | 13 | [![PRs Welcome](https://img.shields.io/badge/PRs-Are%20welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com) [![Commitizen friendly](https://img.shields.io/badge/Commitizen-Friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/) [![License](https://img.shields.io/github/license/syneki/notion-cms?label=License&style=flat-square)](LICENCE) 14 | 15 | [![@notion-render/client](https://img.shields.io/npm/v/@notion-render/client?label=%40notion-render%2Fclient&style=flat-square)](https://www.npmjs.com/package/@notion-render/client) 16 | 17 | [🔨 Install](#🔨-install) • [🚀 Get started](#🚀-get-started) • [⚛ Renderers](#⚛-renderers) • [🎲 Blocks](#🎲-blocks) • [🔧 Extend](#🔧-extend) 18 | 19 | [Contribute](#contributing) • [License](#license) 20 | 21 |
22 | 23 | # ⚠ Pre-release 24 | 25 | This project is currently in pre-release, you can use it but some features are lacking and core components are still able to change. 26 | 27 | Do not hesitate to open an issue to provide your feedback, report bugs and to propose new features. 28 | 29 | # 🔨 Install 30 | 31 | ```shell 32 | $ npm install @notion-render/client 33 | $ yarn add @notion-render/client 34 | ``` 35 | 36 | # 🚀 Get started 37 | 38 | ```typescript 39 | import { Client } from '@notionhq/notion'; 40 | import { NotionRenderer } from '@notion-render/client'; 41 | 42 | const client = new Client({ 43 | auth: process.env.NOTION_TOKEN, 44 | }); 45 | 46 | const renderer = new NotionRenderer(); 47 | 48 | const { results } = await client.blocks.children.list({ 49 | block_id: '', 50 | }); 51 | 52 | const html = renderer.render(...results); 53 | ``` 54 | 55 | # ⚛ Renderers 56 | 57 | | Renderer | Status | 58 | | -------- | -------------- | 59 | | HTML | 🔶 In progress | 60 | | Markdown | ❌ Planned | 61 | 62 | # 🎲 Blocks 63 | 64 | | Block Type | Supported | Notion client required | Available in | Notes | 65 | | --- | --- | --- | --- | --- | 66 | | Text | ✅ Yes | | `@notion-render/client` | `` | 67 | | Bookmark | ✅ Yes | | `@notion-render/client` | Uses `url-metadata` to generate bookmark | 68 | | Breadcrumb | ❌ Missing | | | Embedded preview of external URL | 69 | | Bulleted List Item | ✅ Yes | | `@notion-render/client` | `
  • ` | 70 | | Callout | ✅ Yes | | `@notion-render/client` | `
    ` | 71 | | Child database | ❌ Missing | | | | 72 | | Child page | ❌ Missing | | | | 73 | | Code | ✅ Yes | | `@notion-render/client` |
     |
     74 | | Column List | ✅ Yes | ⚠ Yes | `@notion-render/client` | `
    ` | 75 | | Column | ✅ Yes | ⚠ Yes | `@notion-render/client` | `
    ` | 76 | | Divider | ✅ Yes | | `@notion-render/client` | `
    ` | 77 | | Embed | ❌ Missing | | | | 78 | | Equations | ❌ Missing | | | | 79 | | Files | ❌ Missing | | | | 80 | | Heading 1 | ✅ Yes | | `@notion-render/client` | `

    ` | 81 | | Heading 2 | ✅ Yes | | `@notion-render/client` | `

    ` | 82 | | Heading 3 | ✅ Yes | | `@notion-render/client` | `

    ` | 83 | | Toggle Heading 1 | ✅ Yes | ⚠ Yes | `@notion-render/client` | `

    ` Requires Notion client | 84 | | Toggle Heading 2 | ✅ Yes | ⚠ Yes | `@notion-render/client` | `

    ` Requires Notion client | 85 | | Toggle Heading 3 | ✅ Yes | ⚠ Yes | `@notion-render/client` | `

    ` Requires Notion client | 86 | | Image | ✅ Yes | | `@notion-render/client` | `` | 87 | | Link preview | ❌ Missing | | | | 88 | | Mention | ✅ Yes | | `@notion-render/client` | `` Returns plain text (e.g. @John Doe) | 89 | | Numbered List Item | ✅ Yes | | `@notion-render/client` | `
    1. ` | 90 | | Paragraph | ✅ Yes | | `@notion-render/client` | `

      ` | 91 | | PDF | ❌ Missing | | | | 92 | | Quote | ✅ Yes | | `@notion-render/client` | `

      ` | 93 | | Synced block | ❌ Missing | | | | 94 | | Table | 🔶 Not fully supported | | `@notion-render/client` | `` Header row and column not supported | 95 | | Table Row | 🔶 Not fully supported | | `@notion-render/client` | `` Header row and column not supported | 96 | | Table of contents | ❌ Missing | | | | 97 | | Template | ❌ Deprecated | | | | 98 | | To do | ✅ Yes | | `@notion-render/client` | `
      • ` | 99 | | Toggle | ✅ Yes | ⚠ Yes | `@notion-render/client` | `
        ` | 100 | | Video | ❌ Missing | | | | 101 | 102 | # 🔧 Extend 103 | 104 | ## Custom renderer 105 | 106 | You can create custom renderers to handle custom Notion plugins and override existing blocks. 107 | 108 | ```typescript 109 | import { NotionRenderer, createBlockRenderer } from '@syneki/notion-render'; 110 | 111 | const paragraphRenderer = createBlockRenderer( 112 | 'paragraph', 113 | (data, renderer) => { 114 | return `

        ${renderer.render(...data.paragraph.rich_text)}

        `; 115 | } 116 | ); 117 | 118 | const renderer = new NotionRenderer({ 119 | renderers: [paragraphRenderer], 120 | }); 121 | ``` 122 | 123 | # Contributing 124 | 125 | I'd love for you to contribute to this project. You can request new features by creating an issue, or submit a pull request with your contribution. 126 | 127 | # Licence 128 | 129 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 130 | 131 | ``` 132 | http://www.apache.org/licenses/LICENSE-2.0 133 | ``` 134 | 135 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 136 | -------------------------------------------------------------------------------- /apps/docs/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["next"], 3 | "parserOptions": { 4 | "project": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /apps/docs/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | # local env files 28 | .env*.local 29 | 30 | # vercel 31 | .vercel 32 | 33 | # typescript 34 | *.tsbuildinfo 35 | next-env.d.ts 36 | 37 | .contentlayer -------------------------------------------------------------------------------- /apps/docs/.lintstagedrc.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const buildEslintCommand = (filenames) => 4 | `next lint --fix --file ${filenames 5 | .map((f) => path.relative(process.cwd(), f)) 6 | .join(' --file ')}`; 7 | 8 | module.exports = { 9 | '*.{js,jsx,ts,tsx}': [buildEslintCommand], 10 | }; 11 | -------------------------------------------------------------------------------- /apps/docs/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "../../node_modules/typescript/lib", 3 | "typescript.enablePromptUseWorkspaceTsdk": true 4 | } -------------------------------------------------------------------------------- /apps/docs/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # docs 2 | 3 | ## 0.0.1-alpha.1 4 | 5 | ### Patch Changes 6 | 7 | - Refactor monorepository 8 | - Updated dependencies 9 | - @notion-render/bookmark-plugin@0.0.1-alpha.1 10 | - @notion-render/hljs-plugin@0.0.1-alpha.1 11 | - @notion-render/client@0.0.1-alpha.1 12 | -------------------------------------------------------------------------------- /apps/docs/README.md: -------------------------------------------------------------------------------- 1 | This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). 2 | 3 | ## Getting Started 4 | 5 | First, run the development server: 6 | 7 | ```bash 8 | npm run dev 9 | # or 10 | yarn dev 11 | # or 12 | pnpm dev 13 | ``` 14 | 15 | Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. 16 | 17 | You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. 18 | 19 | [http://localhost:3000/api/hello](http://localhost:3000/api/hello) is an endpoint that uses [Route Handlers](https://beta.nextjs.org/docs/routing/route-handlers). This endpoint can be edited in `app/api/hello/route.ts`. 20 | 21 | This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. 22 | 23 | ## Learn More 24 | 25 | To learn more about Next.js, take a look at the following resources: 26 | 27 | - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. 28 | - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. 29 | 30 | You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! 31 | 32 | ## Deploy on Vercel 33 | 34 | The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. 35 | 36 | Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. 37 | -------------------------------------------------------------------------------- /apps/docs/contentlayer.config.js: -------------------------------------------------------------------------------- 1 | import { defineDatabase, makeSource } from 'contentlayer-source-notion'; 2 | import oSlugify from 'slugify'; 3 | import hljs from '@notion-render/hljs-plugin'; 4 | import bookmark from '@notion-render/bookmark-plugin'; 5 | import { NotionRenderer } from '@notion-render/client'; 6 | import { Client } from '@notionhq/client'; 7 | 8 | const slugify = (value) => 9 | oSlugify(value, { remove: /[*+~.()'#?/"!:@]/g, lower: true }); 10 | 11 | const client = new Client({ auth: process.env.NOTION_TOKEN }); 12 | const renderer = new NotionRenderer({ client }); 13 | 14 | renderer.use(hljs()); 15 | renderer.use(bookmark()); 16 | 17 | export const Guide = defineDatabase(() => ({ 18 | name: 'Guide', 19 | databaseId: '846e5e1e0c2a428285998ff9485ab822', 20 | properties: [ 21 | { 22 | name: 'Name', 23 | required: true, 24 | }, 25 | ], 26 | computedFields: { 27 | slug: { 28 | type: 'string', 29 | resolve: (d) => slugify(d.name), 30 | }, 31 | }, 32 | })); 33 | 34 | export const Block = defineDatabase(() => ({ 35 | name: 'Block', 36 | databaseId: '25bc244c88b3467ba01a35b4b18b4426', 37 | properties: [ 38 | { 39 | name: 'Name', 40 | required: true, 41 | }, 42 | ], 43 | computedFields: { 44 | slug: { 45 | type: 'string', 46 | resolve: (d) => slugify(d.name), 47 | }, 48 | }, 49 | })); 50 | 51 | export const Plugin = defineDatabase(() => ({ 52 | name: 'Plugin', 53 | databaseId: 'f9d9f194bb4e4d068c8a5ede8965540d', 54 | properties: [ 55 | { 56 | name: 'Name', 57 | required: true, 58 | }, 59 | ], 60 | computedFields: { 61 | slug: { 62 | type: 'string', 63 | resolve: (d) => slugify(d.name), 64 | }, 65 | }, 66 | })); 67 | 68 | export default makeSource({ 69 | client, 70 | renderer, 71 | databaseTypes: [Block, Guide, Plugin], 72 | }); 73 | -------------------------------------------------------------------------------- /apps/docs/next.config.js: -------------------------------------------------------------------------------- 1 | const { withContentlayer } = require('next-contentlayer'); 2 | 3 | /** @type {import('next').NextConfig} */ 4 | const nextConfig = { 5 | experimental: { 6 | appDir: true, 7 | }, 8 | }; 9 | 10 | module.exports = withContentlayer(nextConfig); 11 | -------------------------------------------------------------------------------- /apps/docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docs", 3 | "version": "0.0.1-alpha.1", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint", 10 | "lint:fix": "next lint --fix" 11 | }, 12 | "dependencies": { 13 | "@notion-render/bookmark-plugin": "workspace:*", 14 | "@notion-render/client": "workspace:*", 15 | "@notion-render/hljs-plugin": "workspace:*", 16 | "@notionhq/client": "^2.2.5", 17 | "@types/node": "18.16.3", 18 | "@types/react": "18.2.0", 19 | "@types/react-dom": "18.2.1", 20 | "autoprefixer": "10.4.14", 21 | "contentlayer": "0.3.1", 22 | "contentlayer-source-notion": "^0.0.1-alpha.24", 23 | "eslint": "8.39.0", 24 | "eslint-config-next": "13.3.4", 25 | "next": "13.3.4", 26 | "next-contentlayer": "0.3.1", 27 | "postcss": "8.4.23", 28 | "react": "18.2.0", 29 | "react-dom": "18.2.0", 30 | "slugify": "^1.6.6", 31 | "tailwindcss": "3.3.2", 32 | "typescript": "5.0.4" 33 | }, 34 | "devDependencies": { 35 | "sass": "^1.62.1" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /apps/docs/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /apps/docs/public/next.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /apps/docs/public/vercel.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /apps/docs/src/app/Sidebar.tsx: -------------------------------------------------------------------------------- 1 | 'use client'; 2 | 3 | import Link from 'next/link'; 4 | import { usePathname } from 'next/navigation'; 5 | import { useMemo } from 'react'; 6 | 7 | interface Item { 8 | name: string; 9 | slug: string; 10 | items?: Item[]; 11 | } 12 | 13 | export interface NavbarArgs { 14 | items: Item[]; 15 | } 16 | 17 | const NavbarItem = ({ name, slug, items }: Item) => { 18 | const pathname = usePathname(); 19 | const active = useMemo( 20 | () => (items ? pathname.includes(slug) : pathname === slug), 21 | [pathname, slug, items] 22 | ); 23 | 24 | if (items) { 25 | return ( 26 |
        27 | 28 | {name} 29 | 30 |
        31 | {items.map((item) => ( 32 | 33 | ))} 34 |
        35 |
        36 | ); 37 | } 38 | 39 | return ( 40 | 45 | {name} 46 | 47 | ); 48 | }; 49 | 50 | export default function Navbar({ items }: NavbarArgs) { 51 | return ( 52 |
        53 | {items.map((item) => ( 54 | 55 | ))} 56 |
        57 | ); 58 | } 59 | -------------------------------------------------------------------------------- /apps/docs/src/app/blocks/[slug]/page.tsx: -------------------------------------------------------------------------------- 1 | import { allBlocks } from '@contentlayer/generated'; 2 | 3 | export default function Page({ params }: { params: { slug: string } }) { 4 | const block = allBlocks.find((block) => block.slug === params.slug); 5 | return block ? ( 6 |
        7 |

        {block.name}

        8 |
        9 | {block.description &&

        {block.description}

        } 10 |
        11 | Block Type: "{block.blockType}" 12 |
        13 |
        14 | Require Client: {block.requireClient ? 'Yes' : 'No'} 15 |
        16 |
        17 | Parameters: 18 |
          19 | {block.parameters.map((param) => ( 20 |
        • {param}
        • 21 | ))} 22 |
        23 |
        24 | 29 |
        30 |
        34 |
        35 | ) : ( 36 |
        Not found
        37 | ); 38 | } 39 | -------------------------------------------------------------------------------- /apps/docs/src/app/blocks/page.tsx: -------------------------------------------------------------------------------- 1 | export default function Page() { 2 | return

        Blocks

        ; 3 | } 4 | -------------------------------------------------------------------------------- /apps/docs/src/app/guides/[slug]/page.tsx: -------------------------------------------------------------------------------- 1 | import { allGuides } from '@contentlayer/generated'; 2 | 3 | export default function Page({ params }: { params: { slug: string } }) { 4 | const page = allGuides.find((guide) => guide.slug === params.slug); 5 | 6 | return page ? ( 7 |
        8 |

        {page.name}

        9 |
        13 |
        14 | ) : ( 15 |
        Not found
        16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /apps/docs/src/app/head.tsx: -------------------------------------------------------------------------------- 1 | export default function Head() { 2 | return ( 3 | <> 4 | 5 | 6 | 7 | 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /apps/docs/src/app/layout.tsx: -------------------------------------------------------------------------------- 1 | import './styles.scss'; 2 | 3 | import { allBlocks, allGuides, allPlugins } from '@contentlayer/generated'; 4 | 5 | import Sidebar, { NavbarArgs } from './Sidebar'; 6 | 7 | export default function RootLayout({ 8 | children, 9 | }: { 10 | children: React.ReactNode; 11 | }) { 12 | const blocks = allBlocks.sort((a, b) => 13 | a.name < b.name ? -1 : a.name > b.name ? 1 : 0 14 | ); 15 | 16 | const guides = allGuides.sort((a, b) => 17 | (a.order ?? 0) > (b.order ?? 0) ? 1 : -1 18 | ); 19 | 20 | const plugins = allPlugins.sort((a, b) => 21 | a.name < b.name ? -1 : a.name > b.name ? 1 : 0 22 | ); 23 | 24 | const items: NavbarArgs['items'] = [ 25 | { 26 | name: 'Guides', 27 | slug: '/guides', 28 | items: guides.map((guide) => ({ 29 | name: guide.name, 30 | slug: `/guides/${guide.slug}`, 31 | })), 32 | }, 33 | { 34 | name: 'Blocks', 35 | slug: '/blocks', 36 | items: blocks.map((block) => ({ 37 | name: block.name, 38 | slug: `/blocks/${block.slug}`, 39 | })), 40 | }, 41 | { 42 | name: 'Plugins', 43 | slug: '/plugins', 44 | items: plugins.map((plugin) => ({ 45 | name: plugin.name, 46 | slug: `/plugins/${plugin.slug}`, 47 | })), 48 | }, 49 | ]; 50 | 51 | return ( 52 | 53 | 54 | 55 |
        56 | 57 |
        {children}
        58 |
        59 | 60 | 61 | ); 62 | } 63 | -------------------------------------------------------------------------------- /apps/docs/src/app/page.tsx: -------------------------------------------------------------------------------- 1 | export default function Page() { 2 | return
        Hello!
        ; 3 | } 4 | -------------------------------------------------------------------------------- /apps/docs/src/app/plugins/[slug]/page.tsx: -------------------------------------------------------------------------------- 1 | import { allPlugins } from '@contentlayer/generated'; 2 | 3 | export default function Page({ params }: { params: { slug: string } }) { 4 | const page = allPlugins.find((plugin) => plugin.slug === params.slug); 5 | 6 | return page ? ( 7 |
        8 |

        {page.name}

        9 |
        13 |
        14 | ) : ( 15 |
        Not found
        16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles.scss: -------------------------------------------------------------------------------- 1 | @import '@notion-render/client/sass/theme.scss'; 2 | @import 'highlight.js/styles/github.css'; 3 | 4 | @tailwind base; 5 | @tailwind components; 6 | @tailwind utilities; 7 | 8 | body { 9 | min-height: 100vh; 10 | position: relative; 11 | } 12 | 13 | ul { 14 | list-style-type: disc; 15 | list-style-position: inside; 16 | } 17 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/_blocks.scss: -------------------------------------------------------------------------------- 1 | .notion-render { 2 | @import 'blocks/bookmark.scss'; 3 | @import 'blocks/headings.scss'; 4 | @import 'blocks/paragraph.scss'; 5 | @import 'blocks/code.scss'; 6 | @import 'blocks/divider.scss'; 7 | @import 'blocks/callout.scss'; 8 | @import 'blocks/quote.scss'; 9 | @import 'blocks/to-do.scss'; 10 | @import 'blocks/bulleted-list.scss'; 11 | @import 'blocks/numbered-list.scss'; 12 | @import 'blocks/columns.scss'; 13 | @import 'blocks/images.scss'; 14 | @import 'blocks/toggle.scss'; 15 | @import 'blocks/toggle-heading.scss'; 16 | @import 'blocks/table.scss'; 17 | } 18 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/blocks/bookmark.scss: -------------------------------------------------------------------------------- 1 | a.notion-bookmark { 2 | display: flex; 3 | border: 1px solid rgba(55, 53, 47, 0.16); 4 | border-radius: 3px; 5 | flex-wrap: wrap-reverse; 6 | align-items: stretch; 7 | overflow: hidden; 8 | position: relative; 9 | 10 | .bookmark-info { 11 | flex: 4 1 180px; 12 | padding: 12px 14px 14px; 13 | overflow: hidden; 14 | 15 | .bookmark-title { 16 | font-size: 14px; 17 | margin-bottom: 2px; 18 | min-height: 24px; 19 | line-height: 20px; 20 | color: rgb(55, 53, 47); 21 | overflow: hidden; 22 | } 23 | 24 | .bookmark-description { 25 | font-size: 12px; 26 | line-height: 16px; 27 | color: rgba(55, 53, 47, 0.65); 28 | height: 32px; 29 | overflow: hidden; 30 | } 31 | } 32 | 33 | .bookmark-footer { 34 | display: flex; 35 | margin-top: 12px; 36 | 37 | .bookmark-logo { 38 | min-width: 16px; 39 | margin-right: 6px; 40 | width: 16px; 41 | height: 16px; 42 | } 43 | 44 | .bookmark-url { 45 | font-size: 12px; 46 | line-height: 16px; 47 | color: rgb(55, 53, 47); 48 | white-space: nowrap; 49 | overflow: hidden; 50 | text-overflow: ellipsis; 51 | } 52 | } 53 | 54 | .bookmark-thumbnail { 55 | display: block; 56 | flex: 1 1 180px; 57 | position: relative; 58 | img { 59 | position: absolute; 60 | top: 50%; 61 | left: 50%; 62 | transform: translate(-50%, -50%); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/blocks/bulleted-list.scss: -------------------------------------------------------------------------------- 1 | @use '../mixins/colors'; 2 | 3 | ul { 4 | list-style-type: disc; 5 | list-style-position: inside; 6 | li { 7 | margin-top: 1px; 8 | margin-bottom: 1px; 9 | padding-left: 12px; 10 | padding-top: 3px; 11 | padding-bottom: 2px; 12 | 13 | @include colors.background-color; 14 | @include colors.foreground-color; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/blocks/callout.scss: -------------------------------------------------------------------------------- 1 | @use '../mixins/colors'; 2 | 3 | blockquote.notion-callout { 4 | margin-top: 4px; 5 | margin-bottom: 4px; 6 | padding: 16px 16px 16px 12px; 7 | display: flex; 8 | border-radius: 3px; 9 | 10 | @include colors.background-color; 11 | @include colors.foreground-color; 12 | 13 | .icon { 14 | height: 24px; 15 | width: 24px; 16 | border-radius: 0.25em; 17 | display: flex; 18 | align-items: center; 19 | justify-content: center; 20 | } 21 | 22 | .content { 23 | margin-left: 8px; 24 | padding-left: 2px; 25 | padding-right: 2px; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/blocks/code.scss: -------------------------------------------------------------------------------- 1 | div.notion-code { 2 | pre { 3 | code { 4 | display: block; 5 | padding: 34px 16px 32px 32px; 6 | background-color: rgb(247, 246, 243); 7 | border-radius: 3px; 8 | overflow-x: auto; 9 | } 10 | } 11 | legend { 12 | padding-top: 6px; 13 | padding-left: 6px; 14 | padding-left: 2px; 15 | line-height: 1.4; 16 | font-size: 14px; 17 | color: rgba(55, 53, 47, 0.65); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/blocks/columns.scss: -------------------------------------------------------------------------------- 1 | div.notion-column_list { 2 | display: flex; 3 | 4 | div.notion-column { 5 | flex: 1; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/blocks/divider.scss: -------------------------------------------------------------------------------- 1 | hr { 2 | margin-top: 7.5px; 3 | margin-bottom: 7.5px; 4 | } 5 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/blocks/headings.scss: -------------------------------------------------------------------------------- 1 | h1, 2 | h2, 3 | h3 { 4 | line-height: 1.3; 5 | padding: 3px 2px; 6 | } 7 | 8 | h1 { 9 | font-size: 1.875em; 10 | margin-top: 1.1em; 11 | margin-bottom: 4px; 12 | font-weight: 600; 13 | } 14 | 15 | h2 { 16 | font-size: 1.5em; 17 | margin-top: 0.93em; 18 | margin-bottom: 1px; 19 | font-weight: 600; 20 | } 21 | 22 | h3 { 23 | font-size: 1.25em; 24 | margin-top: 0.8em; 25 | margin-bottom: 1px; 26 | font-weight: 600; 27 | } 28 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/blocks/images.scss: -------------------------------------------------------------------------------- 1 | figure { 2 | legend { 3 | padding-top: 6px; 4 | padding-left: 6px; 5 | padding-left: 2px; 6 | line-height: 1.4; 7 | font-size: 14px; 8 | color: rgba(55, 53, 47, 0.65); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/blocks/numbered-list.scss: -------------------------------------------------------------------------------- 1 | @use '../mixins/colors'; 2 | 3 | ol { 4 | list-style-type: decimal; 5 | list-style-position: inside; 6 | li { 7 | margin-top: 1px; 8 | margin-bottom: 1px; 9 | padding-left: 12px; 10 | padding-top: 3px; 11 | padding-bottom: 2px; 12 | 13 | @include colors.background-color; 14 | @include colors.foreground-color; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/blocks/paragraph.scss: -------------------------------------------------------------------------------- 1 | p { 2 | min-height: 1.87em; 3 | margin-top: 1px; 4 | margin-bottom: 1px; 5 | padding: 3px 2px; 6 | } 7 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/blocks/quote.scss: -------------------------------------------------------------------------------- 1 | @use '../mixins/colors'; 2 | 3 | blockquote.notion-quote { 4 | margin: 7px 2px; 5 | padding-left: 14px; 6 | padding-right: 14px; 7 | border-left: 3px solid currentcolor; 8 | 9 | @include colors.background-color; 10 | @include colors.foreground-color; 11 | } 12 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/blocks/table.scss: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | border-spacing: 0; 4 | tr td { 5 | border: 1px solid rgb(233, 233, 231); 6 | min-width: 120px; 7 | max-width: 240px; 8 | min-height: 32px; 9 | vertical-align: top; 10 | padding: 7px 9px; 11 | color: rgb(55, 53, 47); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/blocks/to-do.scss: -------------------------------------------------------------------------------- 1 | @use '../mixins/colors'; 2 | 3 | ul.notion-to_do_list { 4 | li { 5 | margin-top: 1px; 6 | margin-bottom: 1px; 7 | padding-left: 2px; 8 | padding-top: 3px; 9 | padding-bottom: 2px; 10 | display: flex; 11 | 12 | @include colors.background-color; 13 | @include colors.foreground-color; 14 | 15 | &[data-checked='true'] { 16 | color: rgba(55, 53, 47, 0.65); 17 | text-decoration: line-through rgba(55, 53, 47, 0.25); 18 | } 19 | 20 | input[type='checkbox'] { 21 | appearance: none; 22 | display: grid; 23 | place-content: center; 24 | pointer-events: none; 25 | 26 | &:checked { 27 | background-color: rgb(35, 131, 226); 28 | border: 0; 29 | 30 | &::before { 31 | display: block; 32 | } 33 | } 34 | 35 | &::before { 36 | content: ''; 37 | width: 0.65em; 38 | height: 0.65em; 39 | box-shadow: inset 1em 1em white; 40 | 41 | display: none; 42 | 43 | clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); 44 | } 45 | 46 | background-color: transparent; 47 | 48 | border-radius: 0; 49 | border: solid 2px currentColor; 50 | 51 | width: 16px; 52 | height: 16px; 53 | margin-top: 4px; 54 | margin-left: 8px; 55 | margin-right: 8px; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/blocks/toggle-heading.scss: -------------------------------------------------------------------------------- 1 | @use '../mixins/colors'; 2 | 3 | details.notion-toggle-heading_1, 4 | details.notion-toggle-heading_2, 5 | details.notion-toggle-heading_3 { 6 | @include colors.background-color; 7 | @include colors.foreground-color; 8 | 9 | &[open] { 10 | h1, 11 | h2, 12 | h3 { 13 | &::before { 14 | transform: rotate(0deg); 15 | } 16 | } 17 | } 18 | 19 | summary { 20 | display: block; 21 | cursor: pointer; 22 | user-select: none; 23 | 24 | h1, 25 | h2, 26 | h3 { 27 | display: flex; 28 | align-items: center; 29 | 30 | &::before { 31 | content: ''; 32 | transform: rotate(-90deg); 33 | width: 0.6875rem; 34 | height: 0.6875rem; 35 | margin: 11px; 36 | box-shadow: inset 1em 1em black; 37 | clip-path: polygon(100% 0%, 5% 0%, 50% 100%); 38 | } 39 | } 40 | } 41 | 42 | p { 43 | padding-left: 33px; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/blocks/toggle.scss: -------------------------------------------------------------------------------- 1 | @use '../mixins/colors'; 2 | 3 | details.notion-toggle { 4 | @include colors.background-color; 5 | @include colors.foreground-color; 6 | 7 | &[open] { 8 | &::before { 9 | transform: rotate(0deg); 10 | } 11 | } 12 | 13 | summary { 14 | display: flex; 15 | cursor: pointer; 16 | user-select: none; 17 | align-items: center; 18 | 19 | &::before { 20 | content: ''; 21 | transform: rotate(-90deg); 22 | width: 0.6875rem; 23 | height: 0.6875rem; 24 | margin: 11px; 25 | box-shadow: inset 1em 1em black; 26 | clip-path: polygon(100% 0%, 5% 0%, 50% 100%); 27 | } 28 | } 29 | 30 | p { 31 | padding-left: 33px; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/mixins/_colors.scss: -------------------------------------------------------------------------------- 1 | @use '../variables/colors'; 2 | 3 | @mixin background-color { 4 | @each $name, $color in colors.$background-colors { 5 | &.notion-color-#{$name}_background { 6 | background-color: $color; 7 | } 8 | } 9 | } 10 | 11 | @mixin foreground-color { 12 | @each $name, $color in colors.$foreground-colors { 13 | &.notion-color-#{$name} { 14 | color: $color; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /apps/docs/src/app/styles/variables/_colors.scss: -------------------------------------------------------------------------------- 1 | $background-colors: ( 2 | 'blue': rgb(231, 243, 248), 3 | 'red': rgb(253, 235, 236), 4 | 'yellow': rgb(251, 243, 219), 5 | 'gray': rgb(241, 241, 239), 6 | 'brown': rgb(244, 238, 238), 7 | 'orange': rgb(251, 236, 221), 8 | 'green': rgb(237, 243, 236), 9 | 'purple': rgba(244, 240, 247, 0.8), 10 | 'pink': rgba(249, 238, 243, 0.8), 11 | ); 12 | 13 | $foreground-colors: ( 14 | 'brown': rgb(159, 107, 83), 15 | 'gray': rgb(120, 119, 116), 16 | 'orange': rgb(217, 115, 13), 17 | 'yellow': rgb(203, 145, 47), 18 | 'green': rgb(68, 131, 97), 19 | 'blue': rgb(51, 126, 169), 20 | 'purple': rgb(144, 101, 176), 21 | 'pink': rgb(193, 76, 138), 22 | 'red': rgb(212, 76, 71), 23 | ); 24 | -------------------------------------------------------------------------------- /apps/docs/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: [ 4 | './src/pages/**/*.{js,ts,jsx,tsx,mdx}', 5 | './src/components/**/*.{js,ts,jsx,tsx,mdx}', 6 | './src/app/**/*.{js,ts,jsx,tsx,mdx}', 7 | ], 8 | theme: { 9 | extend: { 10 | backgroundImage: { 11 | 'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))', 12 | 'gradient-conic': 13 | 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))', 14 | }, 15 | }, 16 | }, 17 | plugins: [], 18 | } 19 | -------------------------------------------------------------------------------- /apps/docs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "forceConsistentCasingInFileNames": true, 9 | "noEmit": true, 10 | "esModuleInterop": true, 11 | "module": "esnext", 12 | "moduleResolution": "node", 13 | "resolveJsonModule": true, 14 | "isolatedModules": true, 15 | "jsx": "preserve", 16 | "incremental": true, 17 | "plugins": [ 18 | { 19 | "name": "next" 20 | } 21 | ], 22 | "paths": { 23 | "@/*": ["./src/*"], 24 | "@contentlayer/generated": ["./.contentlayer/generated"] 25 | } 26 | }, 27 | "include": [ 28 | "next-env.d.ts", 29 | "**/*.ts", 30 | "**/*.tsx", 31 | ".next/types/**/*.ts", 32 | "contentlayer.config.js", 33 | ".contentlayer/generated" 34 | ], 35 | "exclude": ["node_modules"] 36 | } 37 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@commitlint/config-conventional'], 3 | }; 4 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "notion-render", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "engines": { 6 | "node": ">=18" 7 | }, 8 | "scripts": { 9 | "vercel-build": "next build", 10 | "prepare": "npx is-ci || npx husky install", 11 | "build": "turbo build", 12 | "lint": "turbo lint", 13 | "lint:fix": "turbo lint:fix", 14 | "dev": "turbo run dev", 15 | "commit": "cz", 16 | "release:alpha": "yarn build && yarn workspaces foreach --verbose --topological-dev --parallel --no-private npm publish --tolerate-republish --tag=alpha" 17 | }, 18 | "config": { 19 | "commitizen": { 20 | "path": "./node_modules/@commitlint/cz-commitlint" 21 | } 22 | }, 23 | "repository": { 24 | "type": "git", 25 | "url": "https://github.com/kerwanp/notion-render" 26 | }, 27 | "private": true, 28 | "resolutions": { 29 | "@notion-render/client": "workspace:*" 30 | }, 31 | "workspaces": [ 32 | "packages/**", 33 | "apps/docs" 34 | ], 35 | "devDependencies": { 36 | "@changesets/cli": "^2.26.1", 37 | "@commitlint/cli": "^17.6.1", 38 | "@commitlint/config-conventional": "^17.6.1", 39 | "@commitlint/cz-commitlint": "^17.5.0", 40 | "@typescript-eslint/eslint-plugin": "^5.59.2", 41 | "@typescript-eslint/parser": "^5.59.2", 42 | "commitizen": "^4.3.0", 43 | "eslint": "^8.39.0", 44 | "eslint-config-prettier": "^8.8.0", 45 | "eslint-config-turbo": "^1.9.3", 46 | "eslint-plugin-simple-import-sort": "^10.0.0", 47 | "eslint-plugin-turbo": "^1.9.3", 48 | "husky": "^8.0.3", 49 | "is-ci": "^3.0.1", 50 | "lint-staged": "^13.2.2", 51 | "turbo": "^1.9.3", 52 | "typescript": "^5.0.4" 53 | }, 54 | "packageManager": "yarn@3.5.1" 55 | } -------------------------------------------------------------------------------- /packages/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kerwanp/notion-render/d5107bf20244d355e193d2ed914839d65c74e29c/packages/.gitkeep -------------------------------------------------------------------------------- /packages/client/.lintstagedrc: -------------------------------------------------------------------------------- 1 | { 2 | "src/*.{ts,tsx}": "eslint --fix" 3 | } -------------------------------------------------------------------------------- /packages/client/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @notion-render/client 2 | 3 | ## 0.0.1-alpha.2 4 | 5 | ### Patch Changes 6 | 7 | - Fix dependencies linking due to monorepository 8 | 9 | ## 0.0.1-alpha.1 10 | 11 | ### Patch Changes 12 | 13 | - Refactor monorepository 14 | -------------------------------------------------------------------------------- /packages/client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@notion-render/client", 3 | "version": "0.0.1-alpha.2", 4 | "main": "./dist/index.js", 5 | "types": "./dist/index.d.ts", 6 | "scripts": { 7 | "dev": "run build --watch", 8 | "build": "tsc --build", 9 | "lint": "eslint src/**/*.ts", 10 | "lint:fix": "run lint --fix" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/kerwanp/notion-render", 15 | "directory": "packages/client" 16 | }, 17 | "publishConfig": { 18 | "access": "public" 19 | }, 20 | "devDependencies": { 21 | "@notionhq/client": "^2.2.3", 22 | "@types/sanitize-html": "^2.9.0", 23 | "eslint": "^8.39.0", 24 | "typescript": "^5.0.4" 25 | }, 26 | "dependencies": { 27 | "sanitize-html": "^2.10.0" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/client/sass/_blocks.scss: -------------------------------------------------------------------------------- 1 | @import 'blocks/bookmark.scss'; 2 | @import 'blocks/headings.scss'; 3 | @import 'blocks/paragraph.scss'; 4 | @import 'blocks/code.scss'; 5 | @import 'blocks/divider.scss'; 6 | @import 'blocks/callout.scss'; 7 | @import 'blocks/quote.scss'; 8 | @import 'blocks/to-do.scss'; 9 | @import 'blocks/bulleted-list.scss'; 10 | @import 'blocks/numbered-list.scss'; 11 | @import 'blocks/columns.scss'; 12 | @import 'blocks/images.scss'; 13 | @import 'blocks/toggle.scss'; 14 | @import 'blocks/toggle-heading.scss'; 15 | @import 'blocks/table.scss'; 16 | -------------------------------------------------------------------------------- /packages/client/sass/blocks/bookmark.scss: -------------------------------------------------------------------------------- 1 | a.notion-bookmark { 2 | display: flex; 3 | border: 1px solid rgba(55, 53, 47, 0.16); 4 | border-radius: 3px; 5 | flex-wrap: wrap-reverse; 6 | align-items: stretch; 7 | overflow: hidden; 8 | position: relative; 9 | 10 | .bookmark-info { 11 | flex: 4 1 180px; 12 | padding: 12px 14px 14px; 13 | overflow: hidden; 14 | 15 | .bookmark-title { 16 | font-size: 14px; 17 | margin-bottom: 2px; 18 | min-height: 24px; 19 | line-height: 20px; 20 | color: rgb(55, 53, 47); 21 | overflow: hidden; 22 | } 23 | 24 | .bookmark-description { 25 | font-size: 12px; 26 | line-height: 16px; 27 | color: rgba(55, 53, 47, 0.65); 28 | height: 32px; 29 | overflow: hidden; 30 | } 31 | } 32 | 33 | .bookmark-footer { 34 | display: flex; 35 | margin-top: 12px; 36 | 37 | .bookmark-logo { 38 | min-width: 16px; 39 | margin-right: 6px; 40 | width: 16px; 41 | height: 16px; 42 | } 43 | 44 | .bookmark-url { 45 | font-size: 12px; 46 | line-height: 16px; 47 | color: rgb(55, 53, 47); 48 | white-space: nowrap; 49 | overflow: hidden; 50 | text-overflow: ellipsis; 51 | } 52 | } 53 | 54 | .bookmark-thumbnail { 55 | display: block; 56 | flex: 1 1 180px; 57 | position: relative; 58 | img { 59 | position: absolute; 60 | top: 50%; 61 | left: 50%; 62 | transform: translate(-50%, -50%); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /packages/client/sass/blocks/bulleted-list.scss: -------------------------------------------------------------------------------- 1 | @use '../mixins/colors'; 2 | 3 | ul { 4 | list-style-type: disc; 5 | list-style-position: inside; 6 | li { 7 | margin-top: 1px; 8 | margin-bottom: 1px; 9 | padding-left: 12px; 10 | padding-top: 3px; 11 | padding-bottom: 2px; 12 | 13 | @include colors.background-color; 14 | @include colors.foreground-color; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/client/sass/blocks/callout.scss: -------------------------------------------------------------------------------- 1 | @use '../mixins/colors'; 2 | 3 | blockquote.notion-callout { 4 | margin-top: 4px; 5 | margin-bottom: 4px; 6 | padding: 16px 16px 16px 12px; 7 | display: flex; 8 | border-radius: 3px; 9 | 10 | @include colors.background-color; 11 | @include colors.foreground-color; 12 | 13 | .icon { 14 | height: 24px; 15 | width: 24px; 16 | border-radius: 0.25em; 17 | display: flex; 18 | align-items: center; 19 | justify-content: center; 20 | } 21 | 22 | .content { 23 | margin-left: 8px; 24 | padding-left: 2px; 25 | padding-right: 2px; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/client/sass/blocks/code.scss: -------------------------------------------------------------------------------- 1 | div.notion-code { 2 | pre { 3 | code { 4 | display: block; 5 | padding: 34px 16px 32px 32px; 6 | background-color: rgb(247, 246, 243); 7 | border-radius: 3px; 8 | overflow-x: auto; 9 | } 10 | } 11 | legend { 12 | padding-top: 6px; 13 | padding-left: 6px; 14 | padding-left: 2px; 15 | line-height: 1.4; 16 | font-size: 14px; 17 | color: rgba(55, 53, 47, 0.65); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/client/sass/blocks/columns.scss: -------------------------------------------------------------------------------- 1 | div.notion-column_list { 2 | display: flex; 3 | 4 | div.notion-column { 5 | flex: 1; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/client/sass/blocks/divider.scss: -------------------------------------------------------------------------------- 1 | hr { 2 | margin-top: 7.5px; 3 | margin-bottom: 7.5px; 4 | } 5 | -------------------------------------------------------------------------------- /packages/client/sass/blocks/headings.scss: -------------------------------------------------------------------------------- 1 | h1, 2 | h2, 3 | h3 { 4 | line-height: 1.3; 5 | padding: 3px 2px; 6 | } 7 | 8 | h1 { 9 | font-size: 1.875em; 10 | margin-top: 1.1em; 11 | margin-bottom: 4px; 12 | font-weight: 600; 13 | } 14 | 15 | h2 { 16 | font-size: 1.5em; 17 | margin-top: 0.93em; 18 | margin-bottom: 1px; 19 | font-weight: 600; 20 | } 21 | 22 | h3 { 23 | font-size: 1.25em; 24 | margin-top: 0.8em; 25 | margin-bottom: 1px; 26 | font-weight: 600; 27 | } 28 | -------------------------------------------------------------------------------- /packages/client/sass/blocks/images.scss: -------------------------------------------------------------------------------- 1 | figure { 2 | legend { 3 | padding-top: 6px; 4 | padding-left: 6px; 5 | padding-left: 2px; 6 | line-height: 1.4; 7 | font-size: 14px; 8 | color: rgba(55, 53, 47, 0.65); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/client/sass/blocks/numbered-list.scss: -------------------------------------------------------------------------------- 1 | @use '../mixins/colors'; 2 | 3 | ol { 4 | list-style-type: decimal; 5 | list-style-position: inside; 6 | li { 7 | margin-top: 1px; 8 | margin-bottom: 1px; 9 | padding-left: 12px; 10 | padding-top: 3px; 11 | padding-bottom: 2px; 12 | 13 | @include colors.background-color; 14 | @include colors.foreground-color; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/client/sass/blocks/paragraph.scss: -------------------------------------------------------------------------------- 1 | p { 2 | min-height: 1.87em; 3 | margin-top: 1px; 4 | margin-bottom: 1px; 5 | padding: 3px 2px; 6 | } 7 | -------------------------------------------------------------------------------- /packages/client/sass/blocks/quote.scss: -------------------------------------------------------------------------------- 1 | @use '../mixins/colors'; 2 | 3 | blockquote.notion-quote { 4 | margin: 7px 2px; 5 | padding-left: 14px; 6 | padding-right: 14px; 7 | border-left: 3px solid currentcolor; 8 | 9 | @include colors.background-color; 10 | @include colors.foreground-color; 11 | } 12 | -------------------------------------------------------------------------------- /packages/client/sass/blocks/table.scss: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | border-spacing: 0; 4 | tr td { 5 | border: 1px solid rgb(233, 233, 231); 6 | min-width: 120px; 7 | max-width: 240px; 8 | min-height: 32px; 9 | vertical-align: top; 10 | padding: 7px 9px; 11 | color: rgb(55, 53, 47); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/client/sass/blocks/to-do.scss: -------------------------------------------------------------------------------- 1 | @use '../mixins/colors'; 2 | 3 | ul.notion-to_do_list { 4 | li { 5 | margin-top: 1px; 6 | margin-bottom: 1px; 7 | padding-left: 2px; 8 | padding-top: 3px; 9 | padding-bottom: 2px; 10 | display: flex; 11 | 12 | @include colors.background-color; 13 | @include colors.foreground-color; 14 | 15 | &[data-checked='true'] { 16 | color: rgba(55, 53, 47, 0.65); 17 | text-decoration: line-through rgba(55, 53, 47, 0.25); 18 | } 19 | 20 | input[type='checkbox'] { 21 | appearance: none; 22 | display: grid; 23 | place-content: center; 24 | pointer-events: none; 25 | 26 | &:checked { 27 | background-color: rgb(35, 131, 226); 28 | border: 0; 29 | 30 | &::before { 31 | display: block; 32 | } 33 | } 34 | 35 | &::before { 36 | content: ''; 37 | width: 0.65em; 38 | height: 0.65em; 39 | box-shadow: inset 1em 1em white; 40 | 41 | display: none; 42 | 43 | clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); 44 | } 45 | 46 | background-color: transparent; 47 | 48 | border-radius: 0; 49 | border: solid 2px currentColor; 50 | 51 | width: 16px; 52 | height: 16px; 53 | margin-top: 4px; 54 | margin-left: 8px; 55 | margin-right: 8px; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /packages/client/sass/blocks/toggle-heading.scss: -------------------------------------------------------------------------------- 1 | @use '../mixins/colors'; 2 | 3 | details.notion-toggle-heading_1, 4 | details.notion-toggle-heading_2, 5 | details.notion-toggle-heading_3 { 6 | @include colors.background-color; 7 | @include colors.foreground-color; 8 | 9 | &[open] { 10 | h1, 11 | h2, 12 | h3 { 13 | &::before { 14 | transform: rotate(0deg); 15 | } 16 | } 17 | } 18 | 19 | summary { 20 | display: block; 21 | cursor: pointer; 22 | user-select: none; 23 | 24 | h1, 25 | h2, 26 | h3 { 27 | display: flex; 28 | align-items: center; 29 | 30 | &::before { 31 | content: ''; 32 | transform: rotate(-90deg); 33 | width: 0.6875rem; 34 | height: 0.6875rem; 35 | margin: 11px; 36 | box-shadow: inset 1em 1em black; 37 | clip-path: polygon(100% 0%, 5% 0%, 50% 100%); 38 | } 39 | } 40 | } 41 | 42 | p { 43 | padding-left: 33px; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /packages/client/sass/blocks/toggle.scss: -------------------------------------------------------------------------------- 1 | @use '../mixins/colors'; 2 | 3 | details.notion-toggle { 4 | @include colors.background-color; 5 | @include colors.foreground-color; 6 | 7 | &[open] { 8 | &::before { 9 | transform: rotate(0deg); 10 | } 11 | } 12 | 13 | summary { 14 | display: flex; 15 | cursor: pointer; 16 | user-select: none; 17 | align-items: center; 18 | 19 | &::before { 20 | content: ''; 21 | transform: rotate(-90deg); 22 | width: 0.6875rem; 23 | height: 0.6875rem; 24 | margin: 11px; 25 | box-shadow: inset 1em 1em black; 26 | clip-path: polygon(100% 0%, 5% 0%, 50% 100%); 27 | } 28 | } 29 | 30 | p { 31 | padding-left: 33px; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/client/sass/mixins/_colors.scss: -------------------------------------------------------------------------------- 1 | @use '../variables/colors'; 2 | 3 | @mixin background-color { 4 | @each $name, $color in colors.$background-colors { 5 | &.notion-color-#{$name}_background { 6 | background-color: $color; 7 | } 8 | } 9 | } 10 | 11 | @mixin foreground-color { 12 | @each $name, $color in colors.$foreground-colors { 13 | &.notion-color-#{$name} { 14 | color: $color; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/client/sass/theme.scss: -------------------------------------------------------------------------------- 1 | .notion-render { 2 | @import './blocks'; 3 | } 4 | -------------------------------------------------------------------------------- /packages/client/sass/variables/_colors.scss: -------------------------------------------------------------------------------- 1 | $background-colors: ( 2 | 'blue': rgb(231, 243, 248), 3 | 'red': rgb(253, 235, 236), 4 | 'yellow': rgb(251, 243, 219), 5 | 'gray': rgb(241, 241, 239), 6 | 'brown': rgb(244, 238, 238), 7 | 'orange': rgb(251, 236, 221), 8 | 'green': rgb(237, 243, 236), 9 | 'purple': rgba(244, 240, 247, 0.8), 10 | 'pink': rgba(249, 238, 243, 0.8), 11 | ); 12 | 13 | $foreground-colors: ( 14 | 'brown': rgb(159, 107, 83), 15 | 'gray': rgb(120, 119, 116), 16 | 'orange': rgb(217, 115, 13), 17 | 'yellow': rgb(203, 145, 47), 18 | 'green': rgb(68, 131, 97), 19 | 'blue': rgb(51, 126, 169), 20 | 'purple': rgb(144, 101, 176), 21 | 'pink': rgb(193, 76, 138), 22 | 'red': rgb(212, 76, 71), 23 | ); 24 | -------------------------------------------------------------------------------- /packages/client/src/blocks/bookmark-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { BookmarkBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'bookmark', 7 | async (data) => { 8 | return ` 9 | ${data.bookmark.url} 10 | `; 11 | } 12 | ); 13 | -------------------------------------------------------------------------------- /packages/client/src/blocks/bulleted-list-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { BulletedListBlock } from '../extensions/bulleted-list.extension'; 2 | import { createBlockRenderer } from '../utils/create-block-renderer'; 3 | 4 | export default createBlockRenderer( 5 | 'bulleted_list', 6 | async (data, renderer) => { 7 | return `
          ${await renderer.render( 8 | ...data.bulleted_list 9 | )}
        `; 10 | } 11 | ); 12 | -------------------------------------------------------------------------------- /packages/client/src/blocks/bulleted-list-item-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { BulletedListItemBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'bulleted_list_item', 7 | async (data, renderer) => { 8 | return ` 9 |
      • 12 | ${await renderer.render(...data.bulleted_list_item.rich_text)} 13 |
      • 14 | `; 15 | } 16 | ); 17 | -------------------------------------------------------------------------------- /packages/client/src/blocks/callout-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { CalloutBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'callout', 7 | async (data, renderer) => { 8 | return ` 9 |
        12 |
        13 | ${ 14 | data.callout.icon && 15 | (await renderer.render(data.callout.icon)) 16 | } 17 |
        18 |
        19 | ${await renderer.render(...data.callout.rich_text)} 20 |
        21 |
        22 | `; 23 | } 24 | ); 25 | -------------------------------------------------------------------------------- /packages/client/src/blocks/code-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { CodeBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'code', 7 | async (data, renderer) => { 8 | const code = (await renderer.render(...data.code.rich_text)).replace( 9 | /[\u00A0-\u9999<>&]/g, 10 | function (i: string) { 11 | return `&#${i.charCodeAt(0)};`; 12 | } 13 | ); 14 | 15 | return ` 16 |
        17 |
        ${code}
        20 | ${ 21 | data.code.caption.length > 0 22 | ? `${await renderer.render( 23 | ...data.code.caption 24 | )}` 25 | : '' 26 | } 27 |
        28 | `; 29 | } 30 | ); 31 | -------------------------------------------------------------------------------- /packages/client/src/blocks/column-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { ColumnBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'column', 7 | async (data, renderer) => { 8 | return ` 9 |
        10 | ${await renderer.renderBlock(data.id)} 11 |
        12 | `; 13 | } 14 | ); 15 | -------------------------------------------------------------------------------- /packages/client/src/blocks/column-list-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { ColumnListBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'column_list', 7 | async (data, renderer) => { 8 | if (!renderer.client || !data.has_children) return ''; 9 | 10 | return ` 11 |
        12 | ${await renderer.renderBlock(data.id)} 13 |
        14 | `; 15 | } 16 | ); 17 | -------------------------------------------------------------------------------- /packages/client/src/blocks/divider-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { DividerBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'divider', 7 | async (data) => { 8 | return ` 9 |
        10 | `; 11 | } 12 | ); 13 | -------------------------------------------------------------------------------- /packages/client/src/blocks/emoji-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { createBlockRenderer } from '../utils/create-block-renderer'; 2 | 3 | interface EmojiBlock { 4 | type: 'emoji'; 5 | emoji: string; 6 | } 7 | 8 | export default createBlockRenderer( 9 | 'emoji', 10 | async (data) => `${data.emoji}` 11 | ); 12 | -------------------------------------------------------------------------------- /packages/client/src/blocks/heading1-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { Heading1BlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'heading_1', 7 | async (data, renderer) => { 8 | let result = ` 9 |

        12 | ${await renderer.render(...data.heading_1.rich_text)} 13 |

        14 | `; 15 | 16 | if ( 17 | renderer.client && 18 | 'is_toggleable' in data.heading_1 && 19 | data.has_children && 20 | data.heading_1.is_toggleable 21 | ) { 22 | result = ` 23 |
        26 | ${result} 27 | ${await renderer.renderBlock(data.id)} 28 |
        29 | `; 30 | } 31 | 32 | return result; 33 | } 34 | ); 35 | -------------------------------------------------------------------------------- /packages/client/src/blocks/heading2-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { Heading2BlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'heading_2', 7 | async (data, renderer) => { 8 | let result = ` 9 |

        12 | ${await renderer.render(...data.heading_2.rich_text)} 13 |

        14 | `; 15 | 16 | if ( 17 | renderer.client && 18 | 'is_toggleable' in data.heading_2 && 19 | data.has_children && 20 | data.heading_2.is_toggleable 21 | ) { 22 | result = ` 23 |
        26 | ${result} 27 | ${await renderer.renderBlock(data.id)} 28 |
        29 | `; 30 | } 31 | 32 | return result; 33 | } 34 | ); 35 | -------------------------------------------------------------------------------- /packages/client/src/blocks/heading3-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { Heading3BlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'heading_3', 7 | async (data, renderer) => { 8 | let result = ` 9 |

        12 | ${await renderer.render(...data.heading_3.rich_text)} 13 |

        14 | `; 15 | 16 | if ( 17 | renderer.client && 18 | 'is_toggleable' in data.heading_3 && 19 | data.has_children && 20 | data.heading_3.is_toggleable 21 | ) { 22 | result = ` 23 |
        26 | ${result} 27 | ${await renderer.renderBlock(data.id)} 28 |
        29 | `; 30 | } 31 | 32 | return result; 33 | } 34 | ); 35 | -------------------------------------------------------------------------------- /packages/client/src/blocks/image-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { ImageBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'image', 7 | async (data, renderer) => { 8 | const src = 9 | 'file' in data.image ? data.image.file.url : data.image.external.url; 10 | 11 | return ` 12 |
        13 | 14 | ${ 15 | data.image.caption.length > 0 16 | ? `${await renderer.render( 17 | ...data.image.caption 18 | )}` 19 | : '' 20 | } 21 |
        22 | `; 23 | } 24 | ); 25 | -------------------------------------------------------------------------------- /packages/client/src/blocks/mention-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { MentionRichTextItemResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'mention', 7 | async (data) => `${data.plain_text}` 8 | ); 9 | -------------------------------------------------------------------------------- /packages/client/src/blocks/numbered-list-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { NumberedListblock } from '../extensions/numbered-list.extension'; 2 | import { createBlockRenderer } from '../utils/create-block-renderer'; 3 | 4 | export default createBlockRenderer( 5 | 'numbered_list', 6 | async (data, renderer) => { 7 | return `
          ${await renderer.render( 8 | ...data.numbered_list 9 | )}
        `; 10 | } 11 | ); 12 | -------------------------------------------------------------------------------- /packages/client/src/blocks/numbered-list-item-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { NumberedListItemBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'numbered_list_item', 7 | async (data, renderer) => { 8 | return ` 9 |
      • 12 | ${await renderer.render(...data.numbered_list_item.rich_text)} 13 |
      • 14 | `; 15 | } 16 | ); 17 | -------------------------------------------------------------------------------- /packages/client/src/blocks/paragraph-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { ParagraphBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'paragraph', 7 | async (data, renderer) => { 8 | return ` 9 |

        10 | ${await renderer.render(...data.paragraph.rich_text)} 11 |

        12 | `; 13 | } 14 | ); 15 | -------------------------------------------------------------------------------- /packages/client/src/blocks/quote-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { QuoteBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'quote', 7 | async (data, renderer) => { 8 | return ` 9 |
        12 | ${await renderer.render(...data.quote.rich_text)} 13 |
        14 | `; 15 | } 16 | ); 17 | -------------------------------------------------------------------------------- /packages/client/src/blocks/table-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { TableBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'table', 7 | async (data, renderer) => { 8 | return ` 9 |
      10 | ${await renderer.renderBlock(data.id)} 11 |
      12 | `; 13 | } 14 | ); 15 | -------------------------------------------------------------------------------- /packages/client/src/blocks/table-row.renderer.ts.ts: -------------------------------------------------------------------------------- 1 | import { TableRowBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'table_row', 7 | async (data, renderer) => { 8 | return ` 9 | 10 | ${( 11 | await Promise.all( 12 | data.table_row.cells.map( 13 | async (cell) => 14 | `${await renderer.render( 15 | ...cell 16 | )}` 17 | ) 18 | ) 19 | ).join('')} 20 | 21 | `; 22 | } 23 | ); 24 | -------------------------------------------------------------------------------- /packages/client/src/blocks/text-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { TextRichTextItemResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | import sanitizeHtml from 'sanitize-html'; 3 | 4 | import { createBlockRenderer } from '../utils/create-block-renderer'; 5 | 6 | export default createBlockRenderer( 7 | 'text', 8 | async (data) => { 9 | let result = sanitizeHtml(data.plain_text); 10 | 11 | if (data.href) { 12 | result = `${result}`; 13 | } 14 | 15 | if (data.annotations.color !== 'default') { 16 | result = `${result}`; 17 | } 18 | 19 | if (data.annotations.bold) { 20 | result = `${result}`; 21 | } 22 | 23 | if (data.annotations.italic) { 24 | result = `${result}`; 25 | } 26 | 27 | if (data.annotations.strikethrough) { 28 | result = `${result}`; 29 | } 30 | 31 | if (data.annotations.underline) { 32 | result = `${result}`; 33 | } 34 | 35 | if (data.annotations.code) { 36 | result = `${result}`; 37 | } 38 | 39 | return result; 40 | } 41 | ); 42 | -------------------------------------------------------------------------------- /packages/client/src/blocks/to-do-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { ToDoBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'to_do', 7 | async (data, renderer) => { 8 | return ` 9 |
    2. 12 | 15 | ${await renderer.render(...data.to_do.rich_text)} 16 |
    3. 17 | `; 18 | } 19 | ); 20 | -------------------------------------------------------------------------------- /packages/client/src/blocks/to-do-list-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { ToDoListBlock } from '../extensions/to-do-list.extension'; 2 | import { createBlockRenderer } from '../utils/create-block-renderer'; 3 | 4 | export default createBlockRenderer( 5 | 'to_do_list', 6 | async (data, renderer) => { 7 | return `
        ${await renderer.render( 8 | ...data.to_do_list 9 | )}
      `; 10 | } 11 | ); 12 | -------------------------------------------------------------------------------- /packages/client/src/blocks/toggle-block.renderer.ts: -------------------------------------------------------------------------------- 1 | import { ToggleBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { createBlockRenderer } from '../utils/create-block-renderer'; 4 | 5 | export default createBlockRenderer( 6 | 'toggle', 7 | async (data, renderer) => { 8 | if (!renderer.client) return ''; 9 | 10 | return ` 11 |
      14 | ${await renderer.render( 15 | ...data.toggle.rich_text 16 | )} 17 | ${data.has_children ? await renderer.renderBlock(data.id) : ''} 18 |
      19 | `; 20 | } 21 | ); 22 | -------------------------------------------------------------------------------- /packages/client/src/extensions/bulleted-list.extension.ts: -------------------------------------------------------------------------------- 1 | import { BulletedListItemBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { Block, ExtensionFunc } from '../types'; 4 | 5 | export type BulletedListBlock = Block< 6 | 'bulleted_list', 7 | (BulletedListItemBlockObjectResponse & { processed?: boolean })[] 8 | >; 9 | 10 | const bulletedListExtension: ExtensionFunc = async (blocks) => { 11 | let start = false; 12 | let items: BulletedListBlock['bulleted_list'] = []; 13 | const next = []; 14 | 15 | const pushList = () => { 16 | next.push({ 17 | type: 'bulleted_list', 18 | bulleted_list: items, 19 | }); 20 | 21 | start = false; 22 | items = []; 23 | }; 24 | 25 | for (const block of blocks) { 26 | if ('processed' in block && block.processed) { 27 | next.push(block); 28 | continue; 29 | } 30 | 31 | if (block.type === 'bulleted_list_item') { 32 | if (!start) start = true; 33 | 34 | items.push({ 35 | ...(block as BulletedListItemBlockObjectResponse), 36 | processed: true, 37 | }); 38 | } else if (start) { 39 | pushList(); 40 | } else { 41 | next.push(block); 42 | } 43 | } 44 | 45 | if (start) pushList(); 46 | 47 | return next; 48 | }; 49 | 50 | export default bulletedListExtension; 51 | -------------------------------------------------------------------------------- /packages/client/src/extensions/numbered-list.extension.ts: -------------------------------------------------------------------------------- 1 | import { NumberedListItemBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { Block, ExtensionFunc } from '../types'; 4 | 5 | export type NumberedListblock = Block< 6 | 'numbered_list', 7 | (NumberedListItemBlockObjectResponse & { processed?: boolean })[] 8 | >; 9 | 10 | const numberedListExtension: ExtensionFunc = async (blocks) => { 11 | let start = false; 12 | let items: NumberedListblock['numbered_list'] = []; 13 | const next = []; 14 | 15 | const pushList = () => { 16 | next.push({ 17 | type: 'numbered_list', 18 | numbered_list: items, 19 | }); 20 | 21 | start = false; 22 | items = []; 23 | }; 24 | 25 | for (const block of blocks) { 26 | if ('processed' in block && block.processed) { 27 | next.push(block); 28 | continue; 29 | } 30 | 31 | if (block.type === 'numbered_list_item') { 32 | if (!start) start = true; 33 | 34 | items.push({ 35 | ...(block as NumberedListItemBlockObjectResponse), 36 | processed: true, 37 | }); 38 | } else if (start) { 39 | pushList(); 40 | } else { 41 | next.push(block); 42 | } 43 | } 44 | 45 | if (start) pushList(); 46 | 47 | return next; 48 | }; 49 | 50 | export default numberedListExtension; 51 | -------------------------------------------------------------------------------- /packages/client/src/extensions/to-do-list.extension.ts: -------------------------------------------------------------------------------- 1 | import { ToDoBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 2 | 3 | import { Block, ExtensionFunc } from '../types'; 4 | 5 | export type ToDoListBlock = Block< 6 | 'to_do_list', 7 | (ToDoBlockObjectResponse & { processed?: boolean })[] 8 | >; 9 | 10 | const toDoListExtension: ExtensionFunc = async (blocks) => { 11 | let start = false; 12 | let items: ToDoListBlock['to_do_list'] = []; 13 | const next = []; 14 | 15 | const pushList = () => { 16 | next.push({ 17 | type: 'to_do_list', 18 | to_do_list: items, 19 | }); 20 | 21 | start = false; 22 | items = []; 23 | }; 24 | 25 | for (const block of blocks) { 26 | if ('processed' in block && block.processed) { 27 | next.push(block); 28 | continue; 29 | } 30 | 31 | if (block.type === 'to_do') { 32 | if (!start) start = true; 33 | 34 | items.push({ 35 | ...(block as ToDoBlockObjectResponse), 36 | processed: true, 37 | }); 38 | } else if (start) { 39 | pushList(); 40 | } else { 41 | next.push(block); 42 | } 43 | } 44 | 45 | if (start) pushList(); 46 | 47 | return next; 48 | }; 49 | 50 | export default toDoListExtension; 51 | -------------------------------------------------------------------------------- /packages/client/src/globals.ts: -------------------------------------------------------------------------------- 1 | import bookmarkBlockRenderer from './blocks/bookmark-block.renderer'; 2 | import bulletedListBlockRenderer from './blocks/bulleted-list-block.renderer'; 3 | import bulletedListItemBlockRenderer from './blocks/bulleted-list-item-block.renderer'; 4 | import calloutBlockRenderer from './blocks/callout-block.renderer'; 5 | import codeBlockRenderer from './blocks/code-block.renderer'; 6 | import columnBlockRenderer from './blocks/column-block.renderer'; 7 | import columnListBlockRenderer from './blocks/column-list-block.renderer'; 8 | import dividerBlockRenderer from './blocks/divider-block.renderer'; 9 | import emojiBlockRenderer from './blocks/emoji-block.renderer'; 10 | import heading1BlockRenderer from './blocks/heading1-block.renderer'; 11 | import heading2BlockRenderer from './blocks/heading2-block.renderer'; 12 | import heading3BlockRenderer from './blocks/heading3-block.renderer'; 13 | import imageBlockRenderer from './blocks/image-block.renderer'; 14 | import mentionBlockRenderer from './blocks/mention-block.renderer'; 15 | import numberedListBlockRenderer from './blocks/numbered-list-block.renderer'; 16 | import numberedListItemBlockRenderer from './blocks/numbered-list-item-block.renderer'; 17 | import paragraphBlockRenderer from './blocks/paragraph-block.renderer'; 18 | import quoteBlockRenderer from './blocks/quote-block.renderer'; 19 | import tableBlockRenderer from './blocks/table-block.renderer'; 20 | import tableRowRenderer from './blocks/table-row.renderer.ts'; 21 | import textBlockRenderer from './blocks/text-block.renderer'; 22 | import toDoBlockRenderer from './blocks/to-do-block.renderer'; 23 | import toDoListBlockRenderer from './blocks/to-do-list-block.renderer'; 24 | import toggleBlockRenderer from './blocks/toggle-block.renderer'; 25 | import bulletedListExtension from './extensions/bulleted-list.extension'; 26 | import numberedListExtension from './extensions/numbered-list.extension'; 27 | import toDoListExtension from './extensions/to-do-list.extension'; 28 | import { BlockRenderer, ExtensionFunc } from './types'; 29 | 30 | export const BLOCK_RENDERERS: BlockRenderer[] = [ 31 | bookmarkBlockRenderer, 32 | mentionBlockRenderer, 33 | textBlockRenderer, 34 | paragraphBlockRenderer, 35 | imageBlockRenderer, 36 | heading1BlockRenderer, 37 | heading2BlockRenderer, 38 | heading3BlockRenderer, 39 | emojiBlockRenderer, 40 | codeBlockRenderer, 41 | calloutBlockRenderer, 42 | bulletedListBlockRenderer, 43 | bulletedListItemBlockRenderer, 44 | numberedListBlockRenderer, 45 | numberedListItemBlockRenderer, 46 | quoteBlockRenderer, 47 | dividerBlockRenderer, 48 | columnListBlockRenderer, 49 | columnBlockRenderer, 50 | toggleBlockRenderer, 51 | toDoListBlockRenderer, 52 | toDoBlockRenderer, 53 | tableBlockRenderer, 54 | tableRowRenderer, 55 | ]; 56 | 57 | export const EXTENSIONS: ExtensionFunc[] = [ 58 | numberedListExtension, 59 | bulletedListExtension, 60 | toDoListExtension, 61 | ]; 62 | -------------------------------------------------------------------------------- /packages/client/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './notion-renderer'; 2 | export * from './utils/create-block-renderer'; 3 | export * from './plugin'; 4 | -------------------------------------------------------------------------------- /packages/client/src/notion-renderer.ts: -------------------------------------------------------------------------------- 1 | import { Client } from '@notionhq/client'; 2 | 3 | import { BLOCK_RENDERERS, EXTENSIONS } from './globals'; 4 | import { Plugin } from './plugin'; 5 | import { 6 | Block, 7 | BlockRenderer, 8 | BlockRendererFunc, 9 | ExtensionFunc, 10 | } from './types'; 11 | 12 | export interface NotionRendererArgs { 13 | /** 14 | * List of custom renderers. 15 | */ 16 | renderers?: BlockRenderer[]; 17 | 18 | /** 19 | * List of extensions to improve existing blocks. 20 | */ 21 | extensions?: ExtensionFunc[]; 22 | 23 | /** 24 | * NotionClient used to query block children. 25 | * If not defined, blocks with children will not be fully supported. 26 | */ 27 | client?: Client; 28 | } 29 | 30 | export class NotionRenderer { 31 | private renderers: Record> = {}; 32 | private readonly extensions: ExtensionFunc[] = []; 33 | public readonly client?: Client; 34 | 35 | constructor(args: NotionRendererArgs = {}) { 36 | [...BLOCK_RENDERERS, ...(args.renderers ?? [])].forEach((Block) => 37 | this.addBlockRenderer(Block) 38 | ); 39 | 40 | [...EXTENSIONS, ...(args.extensions ?? [])].forEach((extension) => 41 | this.addExtension(extension) 42 | ); 43 | 44 | this.client = args.client; 45 | } 46 | 47 | public addBlockRenderer(renderer: BlockRenderer): void { 48 | this.renderers[renderer.type] = renderer; 49 | } 50 | 51 | public addExtension(extension: ExtensionFunc): void { 52 | this.extensions.push(extension); 53 | } 54 | 55 | public async render(...blocks: Block[]): Promise { 56 | for (const extension of this.extensions) { 57 | blocks = await extension(blocks); 58 | } 59 | 60 | const promises = blocks 61 | .map((block) => { 62 | const renderer = this.renderers[block.type]; 63 | if (!renderer) 64 | console.warn(`There is no renderer for block ${block.type}`); 65 | return { block, renderer }; 66 | }) 67 | .filter(({ renderer }) => Boolean(renderer)) 68 | .map(({ block, renderer }) => renderer!(block, this)); 69 | 70 | return Promise.all(promises).then((result) => result.join('')); 71 | } 72 | 73 | public async renderBlock(blockId: string): Promise { 74 | if (!this.client) 75 | throw new Error( 76 | 'You must define a Notion Client if you want to use this feature.' 77 | ); 78 | 79 | const { results } = await this.client.blocks.children.list({ 80 | block_id: blockId, 81 | }); 82 | return this.render(...(results as Block[])); 83 | } 84 | 85 | public async use(...plugins: ReturnType[]) { 86 | plugins.forEach((plugin) => { 87 | plugin.renderers.forEach((renderer) => this.addBlockRenderer(renderer)); 88 | plugin.extensions.forEach((extension) => this.addExtension(extension)); 89 | }); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /packages/client/src/plugin.ts: -------------------------------------------------------------------------------- 1 | import { BlockRenderer, ExtensionFunc } from './types'; 2 | 3 | export type Plugin = (config: Config) => { 4 | renderers: (BlockRenderer | never)[]; 5 | extensions: (ExtensionFunc | never)[]; 6 | }; 7 | -------------------------------------------------------------------------------- /packages/client/src/types.ts: -------------------------------------------------------------------------------- 1 | import { NotionRenderer } from './notion-renderer'; 2 | 3 | export type Type = new () => T; 4 | 5 | export type Block = { 6 | type: T; 7 | } & { [key in T]: D } & Record; 8 | 9 | export type BlockRendererFunc = ( 10 | data: T, 11 | renderer: NotionRenderer 12 | ) => Promise; 13 | 14 | export type BlockRenderer = BlockRendererFunc & { 15 | type: string; 16 | } & Record; 17 | 18 | export type ExtensionFunc = (blocks: Block[]) => Promise; 19 | -------------------------------------------------------------------------------- /packages/client/src/utils/create-block-renderer.ts: -------------------------------------------------------------------------------- 1 | import { Block, BlockRenderer, BlockRendererFunc } from '../types'; 2 | 3 | export function createBlockRenderer( 4 | type: T['type'], 5 | func: BlockRendererFunc 6 | ): BlockRenderer { 7 | return Object.assign(func, { type }); 8 | } 9 | -------------------------------------------------------------------------------- /packages/client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "compilerOptions": { 4 | "module": "CommonJS", 5 | "rootDir": "./src", 6 | "outDir": "./dist", 7 | "tsBuildInfoFile": "./dist/.tsbuildinfo.json" 8 | }, 9 | "include": ["./src"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/client/types.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'page-metadata-parser'; 2 | -------------------------------------------------------------------------------- /packages/plugins/bookmark/.lintstagedrc: -------------------------------------------------------------------------------- 1 | { 2 | "src/*.{ts,tsx}": "eslint --fix" 3 | } -------------------------------------------------------------------------------- /packages/plugins/bookmark/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @notion-render/bookmark-plugin 2 | 3 | ## 0.0.1-alpha.2 4 | 5 | ### Patch Changes 6 | 7 | - Fix dependencies linking due to monorepository 8 | - Updated dependencies 9 | - @notion-render/client@0.0.1-alpha.2 10 | 11 | ## 0.0.1-alpha.1 12 | 13 | ### Patch Changes 14 | 15 | - Refactor monorepository 16 | - Updated dependencies 17 | - @notion-render/client@0.0.1-alpha.1 18 | -------------------------------------------------------------------------------- /packages/plugins/bookmark/README.md: -------------------------------------------------------------------------------- 1 | # plugins-bookmark-plugin 2 | 3 | This library was generated with [Nx](https://nx.dev). 4 | 5 | ## Building 6 | 7 | Run `nx build plugins-bookmark-plugin` to build the library. 8 | -------------------------------------------------------------------------------- /packages/plugins/bookmark/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@notion-render/bookmark-plugin", 3 | "version": "0.0.1-alpha.2", 4 | "main": "./dist/index.js", 5 | "types": "./dist/index.d.ts", 6 | "type": "module", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/kerwanp/notion-render", 10 | "directory": "packages/plugins/bookmark" 11 | }, 12 | "publishConfig": { 13 | "access": "public" 14 | }, 15 | "scripts": { 16 | "dev": "run build --watch", 17 | "build": "tsc --build", 18 | "lint": "eslint .", 19 | "lint:fix": "run lint --fix" 20 | }, 21 | "dependencies": { 22 | "@notion-render/client": "workspace:*", 23 | "cheerio": "^1.0.0-rc.12" 24 | }, 25 | "devDependencies": { 26 | "@notionhq/client": "^2.2.5", 27 | "eslint": "^8.39.0", 28 | "typescript": "^5.0.4" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/plugins/bookmark/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bookmark-plugin", 3 | "$schema": "../../../node_modules/nx/schemas/project-schema.json", 4 | "sourceRoot": "packages/plugins/bookmark/src", 5 | "projectType": "library", 6 | "targets": { 7 | "build": { 8 | "executor": "@nrwl/vite:build", 9 | "outputs": ["{options.outputPath}"], 10 | "options": { 11 | "outputPath": "dist/packages/plugins/bookmark" 12 | } 13 | }, 14 | "lint": { 15 | "executor": "@nrwl/linter:eslint", 16 | "outputs": ["{options.outputFile}"], 17 | "options": { 18 | "lintFilePatterns": ["packages/plugins/bookmark/**/*.ts"] 19 | } 20 | } 21 | }, 22 | "tags": [] 23 | } 24 | -------------------------------------------------------------------------------- /packages/plugins/bookmark/src/index.ts: -------------------------------------------------------------------------------- 1 | import { createBlockRenderer, Plugin } from '@notion-render/client'; 2 | import { BookmarkBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 3 | import { load } from 'cheerio'; 4 | 5 | const bookmarkBlockRenderer = createBlockRenderer( 6 | 'bookmark', 7 | async (data) => { 8 | const html = await fetch(data.bookmark.url).then((result) => result.text()); 9 | const $ = load(html); 10 | 11 | const title = 12 | $('meta[property="og:title"]').attr('content') ?? 13 | $('meta[name="title"]').attr('content') ?? 14 | $('title').text(); 15 | const description = 16 | $('meta[property="og:description"]').attr('content') ?? 17 | $('meta[name="description"]').attr('content'); 18 | const icon = 19 | $('link[rel="icon"]').attr('href') ?? 20 | $('link[rel="shortcut icon"]').attr('href'); 21 | const image = 22 | $('meta[property="og:image"]').attr('content') ?? 23 | $('meta[property="og:image:url"]').attr('content'); 24 | const website = new URL(data.bookmark.url).origin; 25 | 26 | return ` 27 | 28 |
      29 |
      30 | ${title} 31 |
      32 |

      33 | ${description} 34 |

      35 | 39 |
      40 |
      41 | 42 |
      43 |
      44 | `; 45 | } 46 | ); 47 | 48 | const bookmarkPlugin: Plugin = () => { 49 | return { 50 | renderers: [bookmarkBlockRenderer], 51 | extensions: [], 52 | }; 53 | }; 54 | 55 | export default bookmarkPlugin; 56 | -------------------------------------------------------------------------------- /packages/plugins/bookmark/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.base.json", 3 | "compilerOptions": { 4 | "module": "ESNext", 5 | "rootDir": "./src", 6 | "outDir": "./dist", 7 | "tsBuildInfoFile": "./dist/.tsbuildinfo.json" 8 | }, 9 | "include": ["./src"], 10 | "references": [{ "path": "../../client" }] 11 | } 12 | -------------------------------------------------------------------------------- /packages/plugins/hljs/.lintstagedrc: -------------------------------------------------------------------------------- 1 | { 2 | "src/*.{ts,tsx}": "eslint --fix" 3 | } -------------------------------------------------------------------------------- /packages/plugins/hljs/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @notion-render/hljs-plugin 2 | 3 | ## 0.0.1-alpha.2 4 | 5 | ### Patch Changes 6 | 7 | - Fix dependencies linking due to monorepository 8 | - Updated dependencies 9 | - @notion-render/client@0.0.1-alpha.2 10 | 11 | ## 0.0.1-alpha.1 12 | 13 | ### Patch Changes 14 | 15 | - Refactor monorepository 16 | - Updated dependencies 17 | - @notion-render/client@0.0.1-alpha.1 18 | -------------------------------------------------------------------------------- /packages/plugins/hljs/README.md: -------------------------------------------------------------------------------- 1 | # hljs-plugin 2 | 3 | This library was generated with [Nx](https://nx.dev). 4 | 5 | ## Building 6 | 7 | Run `nx build hljs-plugin` to build the library. 8 | -------------------------------------------------------------------------------- /packages/plugins/hljs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@notion-render/hljs-plugin", 3 | "version": "0.0.1-alpha.2", 4 | "main": "./dist/index.js", 5 | "types": "./dist/index.d.ts", 6 | "type": "module", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/kerwanp/notion-render", 10 | "directory": "packages/plugins/hljs" 11 | }, 12 | "publishConfig": { 13 | "access": "public" 14 | }, 15 | "scripts": { 16 | "dev": "run build --watch", 17 | "build": "tsc --build", 18 | "lint": "eslint src/**/*.ts", 19 | "lint:fix": "run lint --fix" 20 | }, 21 | "dependencies": { 22 | "@notion-render/client": "workspace:*", 23 | "highlight.js": "^11.8.0" 24 | }, 25 | "devDependencies": { 26 | "@notionhq/client": "^2.2.5", 27 | "@types/sanitize-html": "^2.9.0", 28 | "eslint": "^8.39.0", 29 | "typescript": "^5.0.4" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /packages/plugins/hljs/src/index.ts: -------------------------------------------------------------------------------- 1 | import { createBlockRenderer, Plugin } from '@notion-render/client'; 2 | import type { CodeBlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'; 3 | import hljs, { HighlightOptions } from 'highlight.js'; 4 | 5 | type Config = Partial; 6 | 7 | const codeBlockRenderer = (options: Config) => 8 | createBlockRenderer( 9 | 'code', 10 | async (data, renderer) => { 11 | const code = await renderer.render(...data.code.rich_text); 12 | 13 | const result = hljs.highlight(code, { 14 | language: data.code.language, 15 | ...options, 16 | }); 17 | 18 | return ` 19 |
      20 |
      ${
      21 |         result.value
      22 |       }
      23 | ${ 24 | data.code.caption.length > 1 25 | ? `${await renderer.render( 26 | ...data.code.caption 27 | )}` 28 | : '' 29 | } 30 |
      31 | `; 32 | } 33 | ); 34 | 35 | const hljsPlugin: Plugin = (options) => ({ 36 | renderers: [codeBlockRenderer(options)], 37 | extensions: [], 38 | }); 39 | 40 | export default hljsPlugin; 41 | -------------------------------------------------------------------------------- /packages/plugins/hljs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.base.json", 3 | "compilerOptions": { 4 | "module": "ESNext", 5 | "rootDir": "./src", 6 | "outDir": "./dist", 7 | "tsBuildInfoFile": "./dist/.tsbuildinfo.json" 8 | }, 9 | "include": ["./src"], 10 | "references": [{ "path": "../../client" }] 11 | } 12 | -------------------------------------------------------------------------------- /tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "declaration": true, 5 | "declarationMap": true, 6 | "incremental": true, 7 | "isolatedModules": true, 8 | "esModuleInterop": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "lib": ["ES2020", "DOM"], 11 | "moduleResolution": "node", 12 | "sourceMap": true, 13 | "skipLibCheck": true, 14 | "strict": true, 15 | "noUncheckedIndexedAccess": true, 16 | "noErrorTruncation": true, 17 | "target": "ES2020" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base.json", 3 | "compilerOptions": {}, 4 | "include": [], 5 | "references": [ 6 | { "path": "./packages/client" }, 7 | { "path": "./packages/plugins/hljs" }, 8 | { "path": "./packages/plugins/bookmark" } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /turbo.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://turbo.build/schema.json", 3 | "pipeline": { 4 | "build": { 5 | "dependsOn": [ 6 | "^build" 7 | ], 8 | "outputs": [ 9 | "dist/**", 10 | ".next/**", 11 | "!.next/cache/**" 12 | ] 13 | }, 14 | "lint": {}, 15 | "lint:fix": {}, 16 | "dev": { 17 | "persistent": true, 18 | "cache": false 19 | } 20 | } 21 | } --------------------------------------------------------------------------------