1.0.16 • Published 6 months ago

get-details v1.0.16

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Get Details

Fetch package information directly on your web page in an aesthetic manner


Features

  • Runs instantly via CDN <script> tag
  • Config through a single data-get-details attribute
  • Supports multiple elements
  • Available as ES6 module
  • Return JSON without DOM manipulation
  • Supports NPM (default), GitHub and PyPI
  • Custom format reports

Usage

<p class="current-version"></p>
<script src="https://cdn.jsdelivr.net/npm/get-details" data-get-details="package_name"></script>

Extended Configuration

<div data-get-details="package_name, html element, package source, {%report %format}"></div>

Parameters:

data-get-details="[package-name][,][target-element][,][source],[{format}]"

  • 1st parameter (required): Package name to fetch data for.
  • 2nd parameter (optional): Target element selector where the data will be inserted. If not provided, defaults to #package-version, .current-version or any element with the data-get-details attribute.
  • 3rd parameter (optional): The data source (default: npm). Can be npm, github or pypi.
  • 4th parameter (optional): Custom format, specified within {} for personalized reporting.

ES6 Module Usage

Please install npm package

npm i get-details --save-dev

Import and initialize in your JavaScript:

  import getDetails from 'get-details/es.js';
  getDetails();

It still works with data-* but you can add parameters by functions argument

getDetails({ packageName: 'package-name', target: 'target-element', format: '{ %string }' });

Get JSON data only

Please add parameter str = true

const str = getDetails({ packageName: 'package-name', target: 'target-element', format: '{ %string }', str: true });
console.log(str);

Skypack CDN Usage

You can try to import ES6 module directly from CDN:

  import getDetails from 'https://cdn.skypack.dev/get-details/es6.js?min';
  getDetails();

Custom Format

You can customize the format of the fetched package information by passing a specific format string in the data-get-details attribute. This format string can include placeholders that will be dynamically replaced with package data.

Placeholders:

keydescription
%yearThe current year.
%copyThe copyright symbol (©).
%nameThe package name.
%versionThe package version.
%descriptionThe package description.
%homepageThe homepage URL of the package.
%authorThe author's name.
%licenseThe license information.
%last-updateThe last update date of the package.
%starsThe number of stars (for GitHub).
%forksThe number of forks (for GitHub).
%languageThe programming language (for GitHub).
%repositoryThe repository URL.
%maintainersThe names of maintainers.
%downloadsThe download count for the package.
%release-dateThe release date of the package.
%release-notesThe release notes for the latest version.
%ownerThe owner of the repository.
%requiresWhether the package requires Python (for PyPI).

Example of custom format:

  <footer class="footer">
    <p class="copy"></p>
  </footer>

  <script src="https://cdn.jsdelivr.net/npm/get-details" data-get-details="get-details,.copy,npm,{'%year %copy %name %version - (%license)'}"></script>
</body>
</html>

Supported Sources

Currently supports fetching data from NPM, GitHub, PyPI and GitLab.

Supported CDN

ServiceURL
jsDelivrhttps://cdn.jsdelivr.net/npm/get-details
UNPKGhttps://www.unpkg.com/get-details
Skypackhttps://cdn.skypack.dev/get-details

Contributing

Contributions welcome! Feel free to:

  • Fork the repository
  • Submit pull requests
  • File issues
  • Suggest improvements

License

MIT License

1.0.16

6 months ago

1.0.15

6 months ago

1.0.14

6 months ago

1.0.13

6 months ago

1.0.12

6 months ago

1.0.11

6 months ago

1.0.10

6 months ago

1.0.9

6 months ago

1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago