From 92334b3186958f4182bd4a2ad9f8dcedffd90606 Mon Sep 17 00:00:00 2001 From: Denys M Date: Fri, 1 Sep 2023 11:27:49 +0200 Subject: [PATCH] feat: render HTML from djot source --- .prettierrc | 2 +- README.md | 61 +++++------------------------------------ package.json | 4 ++- pnpm-lock.yaml | 20 ++++++++++++++ src/lib/Djot.svelte | 10 +++++++ src/lib/index.js | 4 ++- src/routes/+page.svelte | 11 ++++++-- 7 files changed, 52 insertions(+), 60 deletions(-) create mode 100644 src/lib/Djot.svelte diff --git a/.prettierrc b/.prettierrc index a77fdde..da08664 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,7 +1,7 @@ { "useTabs": true, "singleQuote": true, - "trailingComma": "none", + "trailingComma": "es5", "printWidth": 100, "plugins": ["prettier-plugin-svelte"], "pluginSearchDirs": ["."], diff --git a/README.md b/README.md index 4fee31f..ee81bd3 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,11 @@ -# create-svelte +## Usage -Everything you need to build a Svelte library, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte). +```svelte + -## Creating a project - -If you're seeing this, you've probably already done this step. Congrats! - -```bash -# create a new project in the current directory -npm create svelte@latest - -# create a new project in my-app -npm create svelte@latest my-app -``` - -## Developing - -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: - -```bash -npm run dev - -# or start the server and open the app in a new browser tab -npm run dev -- --open -``` - -Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app. - -## Building - -To build your library: - -```bash -npm run package -``` - -To create a production version of your showcase app: - -```bash -npm run build -``` - -You can preview the production build with `npm run preview`. - -> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment. - -## Publishing - -Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)). - -To publish your library to [npm](https://www.npmjs.com): - -```bash -npm publish + ``` diff --git a/package.json b/package.json index e12514e..53c17e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte-djot", - "version": "0.1.0", + "version": "0.1.1", "scripts": { "dev": "vite dev", "build": "vite build && pnpm run package", @@ -27,6 +27,7 @@ "svelte": "^4.0.0" }, "devDependencies": { + "@djot/djot": "^0.2.3", "@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/kit": "^1.20.4", "@sveltejs/package": "^2.0.0", @@ -40,6 +41,7 @@ "publint": "^0.1.9", "svelte": "^4.0.5", "svelte-check": "^3.4.3", + "svelte-djot": "^0.1.0", "tslib": "^2.4.1", "typescript": "^5.0.0", "vite": "^4.4.2" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 64bf9de..91e85df 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,9 @@ settings: excludeLinksFromLockfile: false devDependencies: + '@djot/djot': + specifier: ^0.2.3 + version: 0.2.3 '@sveltejs/adapter-auto': specifier: ^2.0.0 version: 2.1.0(@sveltejs/kit@1.24.0) @@ -44,6 +47,9 @@ devDependencies: svelte-check: specifier: ^3.4.3 version: 3.5.1(postcss@8.4.29)(svelte@4.2.0) + svelte-djot: + specifier: ^0.1.0 + version: 0.1.0(svelte@4.2.0) tslib: specifier: ^2.4.1 version: 2.6.2 @@ -69,6 +75,12 @@ packages: '@jridgewell/trace-mapping': 0.3.19 dev: true + /@djot/djot@0.2.3: + resolution: {integrity: sha512-5Oa9adc0rP1pK42glgn8Ascxak7oaDAplgTA8e4zqqPJGyPsbpkYWKN+34QhsFlpwHI/B3W2UTr25R9VRcMPCg==} + engines: {node: '>=17.0.0'} + hasBin: true + dev: true + /@esbuild/android-arm64@0.18.20: resolution: {integrity: sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==} engines: {node: '>=12'} @@ -1830,6 +1842,14 @@ packages: - sugarss dev: true + /svelte-djot@0.1.0(svelte@4.2.0): + resolution: {integrity: sha512-SNJnYOLhutgPaXq5G9AhhQO9hPF2qI9IngQydyF/oItYSNzjA9gUpU/n3pBpRU019tyb9x1qlXYf5mzzpyNJMw==} + peerDependencies: + svelte: ^4.0.0 + dependencies: + svelte: 4.2.0 + dev: true + /svelte-eslint-parser@0.33.0(svelte@4.2.0): resolution: {integrity: sha512-5awZ6Bs+Tb/zQwa41PSdcLynAVQTwW0HGyCBjtbAQ59taLZqDgQSMzRlDmapjZdDtzERm0oXDZNE0E+PKJ6ryg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} diff --git a/src/lib/Djot.svelte b/src/lib/Djot.svelte new file mode 100644 index 0000000..3a691f4 --- /dev/null +++ b/src/lib/Djot.svelte @@ -0,0 +1,10 @@ + + +{@html html} diff --git a/src/lib/index.js b/src/lib/index.js index 47d3c46..f2970ca 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -1 +1,3 @@ -// Reexport your entry components here +import Djot from './Djot.svelte'; + +export { Djot }; diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 0a45b69..14dc656 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,3 +1,8 @@ -

Welcome to your library project

-

Create your package using @sveltejs/package and preview/showcase your work with SvelteKit

-

Visit kit.svelte.dev to read the documentation

+ + +