Latest link always CSS or JS?

WIll the main link when browsing packages on cdnjs.com always be a .css or .js file?

Hi @Richienb,

Great question! As far as I know, it can be any file as we pull it from whatever file is referenced as the “filename” property of the library’s package.json file on cdnjs.

Eg. For jQuery, the package.json file lists “jquery.min.js” as the default file, so that is what we display.

Hope that helps,
Matt.

@MattIPv4 In that case, how does CDNjs figure out what text to display in copy dropdowns? For example, for js files, it would display Copy Script Tag and for CSS files it would display Copy Link Tag. How would this be for other extensions?

This wasn’t easy but I went through the code and figured it out.

In reindex.js the file type is extracted by getting the final part of the file name after . and this is saved into Algolia.

Now in public/js/main.js the search results are parsed into HTML and information like filetype is added as a CSS class.

By default the script and link copy buttons are hidden unless the filetype matches.

So to answer your question, for other extensions it will only show the Copy Url option.

1 Like

@Richienb For example:

Exactly that, all the copy options are generated but hidden, if it’s a filetype that has custom copy options, we show them via css.

1 Like