npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

html2svelte

v0.0.1-c

Published

cli for html2svelte

Downloads

7

Readme

html2svelte

Convert HTML to Svelte components in a snap

Svelte is pretty 🔥 and is a nice way to build web apps. This is a small tool that helps turn your HTML into Svelte components.

I especially like that its much easier to design/style an app, and then add logic. This is quite different than React, where you have to think about the logic/components first, and then build/style them.

There are a list of other "reasons why" you should use Svelte, but thats left as an exercise to the reader.

💃 Try it out

Convert HTML to Svelte Instantly ⚡️

💥 TLDR;

Add comp_ to the class names of your HTML elements and run html2svelte on your HTML files.

📦 Install from npm

npm install -g html2svelte

📖 Docs

$ html2svelte help
cli for html2svelte

VERSION
  html2svelte/0.0.1b darwin-x64 node-v16.17.0

USAGE
  $ html2svelte [COMMAND]

COMMANDS
  convert  Convert a HTML file to Svelte Components
  help     Display help for html2svelte
$ html2svelte convert --help
Convert a HTML file to Svelte Components

USAGE
  $ html2svelte convert [FILE]

ARGUMENTS
  FILE  html file to convert

OPTIONS
  -o, --outDir=outDir  [default: build] folder to output the converted
                       files to

  -p, --prefix=prefix  [default: comp_] prefix to used to determine which
                       elements to convert

🛠️ Build from source

git clone https://github.com/drbh/html2svelte.git
cd html2svelte
npm run bootstrap
# now you can run the tool
html2svelte convert assets/index.html
prettier --plugin-search-dir . build/*.svelte -w

⚙️ How it works

  1. The script will look for all the HTML file based on the cli argument passed.
  2. It parses the HTML and look for all the elements with a class name that starts with comp_.
  3. Then it creates a Svelte component for each of those elements, and replace the HTML with the component, writing the new HTML to the build/ folder.
  4. prettier is run with the svelte plugin to format the final code.

🧠 Thoughts

  • [ ] should have built-in prettier support
  • [ ] could/should be a vs code extension
  • [ ] should support more functionality
  • [ ] should handle non single div cases better