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

astro-code-editor

v0.1.1

Published

Embed code editors for YAML, Markdown, JS / TS, JSON… Specifically tailored for each language. Powered by the Monaco Editor and helpers.

Downloads

6

Readme

🚀  Astro — Code Editor 📝

NPM Downloads ISC License PRs Welcome
Astro TypeScript Prettier EditorConfig ESLint

Embed code editors for YAML, Markdown, JS / TS, JSON…
Specifically tailored for each language.

Powered by the Monaco Editor + curated languages helpers.

Goal is to simplify configuration in nicely wrapped, type-safe Astro components, with easy access to created instances, browser side, thanks to Custom Elements.


Warning
🚧  Work-in-progress.

📦  Installation

pnpm i astro-code-editor

Supported languages

Because each language can have their set of settings and externally loaded libraries (like language servers, snippets, typings…), choice has been made to separate them instead of providing a one-size-fit-all editor.

YAML

Using monaco-yaml with YAML language server under the hood.

Monaco YAML live demo / Repository.

Features advanced JSON schema validation / auto-completion, far superior to remark-lint-frontmatter-schema (however this one has the advantage of working in VS Code etc.).

Accepts Markdown input value with front matter automatic extraction.

See the component interface.

Markdown

Soon…

JS / TS

Soon…

JSON

Soon…

🛠  Usage

YAML editor

Full working example:

---
// E.g. `src/pages/editor-demos.astro`

import YAMLEditor from 'astro-code-editor/YAMLEditor.astro';
import Layout from '../layouts/Bare.astro';

/* Remote schema URI — Example: JSON Schema core meta schema */
const coreMetaSchemaUrl = 'http://json-schema.org/draft-07/schema#';

/* —OR— from your Astro `public` folder */
const mySchema = '/schemas/my-schema.yaml';

/* You can use Markdown with frontmatter as source too, not only pure YAML */
const initialValue = `---
title: Hello
description: World
---

# Hello
`;
---

<Layout>
  <header><h1>Demos page!</h1></header>

  <main>
    <editor-demos>
      <section>
        <YAMLEditor
          data-yaml-demo-editor
          schemaUrlRef={coreMetaSchemaUrl}
          value={initialValue}
          extractMarkdownFrontmatter
        />

        <hr />

        <button data-clear>Clear text</button>
      </section>

      <section>…</section>
    </editor-demos>

    <hr />

    <section><em>That's a wrap!</em></section>
  </main>

  <footer>© {new Date().getFullYear()}</footer>
</Layout>
<script>
  // Use YAMLEditor Custom Elem. class definition, for type discrimination below
  import YAMLEditor from 'astro-code-editor/YAMLEditor.client.js';

  // Create a Custom Element for housing our demos (totally optional)

  class EditorDemos extends HTMLElement {
    connectedCallback() {
      const clearButtonElement = this.querySelector('[data-clear]');
      if (!(clearButtonElement instanceof HTMLButtonElement)) return;

      // Assert the createdMonaco editor + model

      const editor = this.querySelector('[data-yaml-demo-editor]');
      if (!(editor instanceof YAMLEditor)) return;

      const model = editor?.model;
      if (!model) return;

      // Current instance model methods are now auto-completed in your IDE
      // `model: editor.ITextModel`

      clearButtonElement.addEventListener('click', () => {
        model.setValue(`# CLEARED! ${new Date().toLocaleString()}`);
      });
    }
  }

  customElements.define('editor-demos', EditorDemos);
</script>
<style lang="scss">
  editor-demos {
    display: block;
    width: 100%;

    & > section {
      max-width: 60vw;
      margin: 0 auto;
    }

    // Editors styles
    // /!\ Don't forget to set editor dimensions /!\

    [data-yaml-demo-editor] {
      width: 800px;
      height: 600px;
    }
  }

  // Other page styles…

  header {
    text-align: center;
    padding-bottom: 4rem;
  }

  footer {
    padding-top: 4rem;
    text-align: center;
  }

  main {
    width: 100%;
  }
</style>

LIVE DEMO  🎭  DOCUMENTATION WEBSITE ⎋

Live demo website

code.juliancataldo.com


🔗  JulianCataldo.com