DEV Community

Cover image for I made DEV.to widget for websites/blogs
Saurabh Daware ๐ŸŒป
Saurabh Daware ๐ŸŒป

Posted on • Edited on

I made DEV.to widget for websites/blogs

Hey Everyone! So I made an (Unofficial) DEV.to widget / profile-card which you can use in your websites and blogs (You just have to copy-paste 2 lines of code :D).

Here's how it looks like

Usage ( JUST 2 LINES OF CODE :D )

    <dev-widget data-username="saurabhdaware"></dev-widget>

    <!-- Place script tag before the end of the body tag -->
    <script src="https://unpkg.com/dev-widget@^1/dist/card.component.min.mjs" type="module"></script>

Enter fullscreen mode Exit fullscreen mode

And BOOM that's it! Just put your dev.to username in data-username attribute and you will get your profile card :D


If you want to install it as ES6 module (Mostly used in frameworks)

npm install --save dev-widget
Enter fullscreen mode Exit fullscreen mode

and import at the top of your file

import 'dev-widget'
Enter fullscreen mode Exit fullscreen mode

Then you can use

<dev-widget data-username="saurabhdaware"></dev-widget>
Enter fullscreen mode Exit fullscreen mode

There are some other attributes like data-width, data-limit You can checkout full documentation on my GitHub:

GitHub logo saurabhdaware / DEV-widget

Unofficial Widget/profile card for https://dev.to/

DEV widget

GitHub package.json version Contributions to DEV Widget are welcomed

GUI to Generate Card: https://dev-widget.netlify.app/create

Codepen: https://codepen.io/saurabhdaware/pen/NWWbOvv

Unofficial Widget / profile card for dev.to.

You can use it in your website/blog and show off your DEV.to articles ๐ŸŒป

Screenshot of the DEV.to Widget


Installation and Usage

- Through script tag

    <dev-widget data-username="saurabhdaware"></dev-widget>

    <!-- Place script tag before the end of the body tag -->
    <script src="https://unpkg.com/dev-widget@^1/dist/card.component.min.mjs" type="module"></script>
Enter fullscreen mode Exit fullscreen mode

- As NPM module

This can be used in React, Vue and almost any other frontend framework

npm install --save dev-widget
Enter fullscreen mode Exit fullscreen mode

Inside your framework component

import 'dev-widget'
Enter fullscreen mode Exit fullscreen mode

Attributes Guide

attributes description default
data-username Your DEV.to Username
data-width Width of the card 300px
data-contentheight Height of the Aricles Container 300px
data-theme Theme of the card (dark, ocean, pink, cobalt2, default) default
data-name (optional) Name to display on card Will
โ€ฆ

Do โญ the repository ๐Ÿฆ„

Also, for the hacktoberfest, if anyone wants to contribute to this project, I would love to help. You can checkout CONTRIBUTING.md for contribution guidelines.

GitHub: https://github.com/saurabhdaware/DEV-widget
NPM: https://npmjs.org/package/dev-widget
Codepen: https://codepen.io/saurabhdaware/pen/NWWbOvv

Oldest comments (55)

Collapse
 
fultonbrowne profile image
Fulton Browne

I will use this on my blog, thanks

Collapse
 
saurabhdaware profile image
Saurabh Daware ๐ŸŒป

so cool! thank you :D

Collapse
 
rose profile image
Rose

Love the idea, well done ๐Ÿ˜Š

Collapse
 
saurabhdaware profile image
Saurabh Daware ๐ŸŒป

Thank you so much ๐Ÿฆ„

Collapse
 
maniflames profile image
Maniflames • Edited

Looks very neat!

Collapse
 
saurabhdaware profile image
Saurabh Daware ๐ŸŒป

Thank you :)

Collapse
 
nickytonline profile image
Nick Taylor

Cool stuff Saurabh!

Collapse
 
saurabhdaware profile image
Saurabh Daware ๐ŸŒป

Thank you so much ๐ŸŒป

Collapse
 
paulasantamaria profile image
Paula Santamarรญa

Looks great, thank you!

Collapse
 
saurabhdaware profile image
Saurabh Daware ๐ŸŒป

Thank you Paula :D

Collapse
 
ben profile image
Ben Halpern

This is so beautifully done. Iโ€™m super impressed.

Collapse
 
saurabhdaware profile image
Saurabh Daware ๐ŸŒป

Thank you so much ben๐ŸŒป means a lot ๐Ÿฆ„๐Ÿฆ„

Collapse
 
loujaybee profile image
Lou (๐Ÿš€ Open Up The Cloud โ˜๏ธ)

Will this create any significant impact on DEV API consumption?

Collapse
 
eaich profile image
Eddie

Amazing dude! A+ for Web Components implementation. Loved how you split the css into a separate module. Very impressive.

Collapse
 
saurabhdaware profile image
Saurabh Daware ๐ŸŒป

Thank youuu ๐Ÿ•บ๐ŸŒป

Collapse
 
artis3n profile image
Ari Kalfus • Edited

This is great. Nit: Promote healthy web practices and add sub-resource integrity (SRI) via the integrity attribute on your example.

developer.mozilla.org/en-US/docs/W...

You can grab your hash from unpkg via the meta query parameter:

https://unpkg.com/dev-widget@1.0.1/dist/card.component.mjs?meta

<script src="https://unpkg.com/dev-widget@1.0.1/dist/card.component.mjs" type="module" integrity="sha384-755Jblzb17ugkA3KRCLz4XS8CPb3xEwBdBMk8ZBw51agtKmppILXMJrKvuTRkUhy"></script>
Collapse
 
saurabhdaware profile image
Saurabh Daware ๐ŸŒป

Oh I didn't know about this thank you so much! I'll check it out

Collapse
 
loujaybee profile image
Lou (๐Ÿš€ Open Up The Cloud โ˜๏ธ)

Came here to say that too โ€” bravo!

Collapse
 
saurabhdaware profile image
Saurabh Daware ๐ŸŒป

Oh thank you! I've added integity hash to my codepen demo. Not really sure how I can get that hash before publishing so that I can set in readme (Apparently that hash changed from 1.0.1 to 1.0.2)

Thread Thread
 
artis3n profile image
Ari Kalfus • Edited

Yup, the hash will change for each version of the script pushed to the CDN.

Collapse
 
prafulla-codes profile image
Prafulla Raichurkar

Cool ๐Ÿคฉ

Collapse
 
saurabhdaware profile image
Saurabh Daware ๐ŸŒป

Thank you Prafulla :D

Collapse
 
deepaksisodiya profile image
Deepak Sisodiya

great

Collapse
 
saurabhdaware profile image
Saurabh Daware ๐ŸŒป

Thank you :D