Giter Site home page Giter Site logo

wxt-examples's Introduction

WXT Examples

To run an example, install dependencies, cd into the directory, and run the wxt dev command.

pnpm i

cd examples/vue-i18n
pnpm dev

Each example is compared against it's relevant template, and it's README is generated based on the diff between the template and example.

Adding Examples

Examples should be based off a template and be as minimal as possible. Do not delete any of the files created by the template if unnecessary.

You can create a new example inside the examples directory like so:

# Create the project base
pnpx wxt@latest init examples/vanilla-i18n --template vanilla --pm pnpm

# Add a README template where the example is explained
touch examples/vanilla-i18n/README.template.md
  • --template vanilla: When listed on https://wxt.dev/examples.html, this is the template whose diff will be compared against
  • examples/vanilla-i18n: Make sure to create the example in the examples directory, and prefix the name with the template it's based off of
  • --pm pmpm: Use pnpm for the package manager to be consistent with this repo. Since we're in a PNPM workspace, the diffs will never display lockfile changes.

Other examples:

pnpx wxt@latest init examples/vue-content-script-ui --template vue --pm pnpm
pnpx wxt@latest init examples/vanilla-tailwind --template vanilla --pm pnpm
pnpx wxt@latest init examples/react-options-page --template react --pm pnpm

Generating README

To generate your example's README, run:

# Update templates and generate READMEs
pnpm -w generate

# Skip updating templates, just generate READMEs
pnpm -w dev:generate

This will take your template file, add diffs/file changes to it, and write a new README.md.

Your README.template.md file should be styled as a walkthrough, referencing individual files as you implement the example. See examples/vue-i18n/README.template.md for an example.

You template can list a few template varialbes that will be replaced when generating the example's README.

  • {{base}}: Replaced with information about which WXT template the example is based off of
  • {{filename}}: Replaced with the filename and diff/contents of the specified file

You can also add YAML frontmatter to the templates, and that frontmatter will be added to examples.json, but removed from the final README. https://wxt.dev uses tags frontmatter to filter examples down in different locations, but it supports any field you add

wxt-examples's People

Contributors

aklinker1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.