Giter Club home page Giter Club logo

eleventy-plugin-add-web-component-definitions's People

Contributors

bennypowers avatar dependabot[bot] avatar gdbaldw avatar jdvivar avatar jdvivar-eb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

eleventy-plugin-add-web-component-definitions's Issues

Plugin interferes with RSS feeds

Hello Daniel,

first of all, thank you so much for the plugin. It does exactly what I was looking for and it saved me a lot of work. Great work! Thank you! โ™ฅ๏ธ

Unfortunately, I'm running into a small issue. I use eleventy to also generate RSS feeds and since I enabled the plugin my RSS broke. ๐Ÿ™ˆ

I debugged a little bit and saw that the plugin changes files with the file type html or files that start with <. The 2nd condition is true for RSS feeds and that leads to malformed feed files.

https://github.com/jdvivar/eleventy-plugin-add-web-component-definitions/blob/master/add-web-component-definitions.js#L25

To solve the issue I see two options:

  1. add an ignore glob config option
  2. change the 2nd condition to content.toLowerCase().startsWith('<!doctype html') (not sure if that's a breaking change though).

Thanks so much for the hard work, and I'm also happy to hand in a PR if you prefer that.

Deal with `permalink: false`

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch [email protected] for the project I'm working on because templates with permalink: false cause an error when running the package.

Here is the diff that solved my problem:

diff --git a/node_modules/eleventy-plugin-add-web-component-definitions/add-web-component-definitions.js b/node_modules/eleventy-plugin-add-web-component-definitions/add-web-component-definitions.js
index 2fbc2d6..da3ac31 100644
--- a/node_modules/eleventy-plugin-add-web-component-definitions/add-web-component-definitions.js
+++ b/node_modules/eleventy-plugin-add-web-component-definitions/add-web-component-definitions.js
@@ -16,6 +16,9 @@ const addChild = (body, child, position) => {
 }
 
 module.exports = function (options, content, outputPath) {
+  if (typeof outputPath !== 'string')
+    return content;
+    
   if (!!options.path && !!options.specifiers) {
     throw new Error('You may configure a path function or import specifiers, but not both')
   }

This issue body was partially generated by patch-package.

Support for the `is` attribute for customized built-in elements

Web components can also be customized built-in elements using the is attribute as long as the web component specifically extends that element. The plugin adds web component definitions based on the tag name but doesn't check for built-in elements using is.

I've actually been messing around with this locally and think I have it working, but didn't want to open a pull request before discussing the feature and checking for contribution requirements.

passing eleventyConfig to path functions

What do you think of passing in the config object?

eleventyConfig.addPlugin(addWebComponentDefinitions, {
  path: (tag, config) => config.environment === 'production'
      ? `/my-project/components/${tag}.js`
      : `/components/${tag}.js`
  }
)
eleventyConfig.addPlugin(addWebComponentDefinitions, {
  specifiers: {
    'custom-tag-one': (tag, config) => `/${config.pathPrefix}/assets/${tag}.js`,
    'custom-tag-two': 'my-module'
  }
)

Would you take a PR to replace JSDom with parse5?

Howdy

I put together an alternate implementation that uses parse5 and hast instead of JSDom, and is quite performant.

Rather than publish under some other name, would you be interested in taking a PR?

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.