Coder Social home page Coder Social logo

blogroll.js's Introduction

blogroll.js

A fun little script to add a simple blogroll to your site. You can can add as many blogs as you like, specify the number of blogs you want to appear at one time, and the script will make sure a new random subset is shown.

Usage

First of all, you need your blogroll data in a json file. (Refer to example-data.json for an example list)

Essentially, it's an array of JSON objects that have both a title and a url. This data is used to populate the blogroll.

It looks something like this:

[
	{
		"title": "Example Blog",
		"url": "https://blog.com"
	}
]

Then you'll need to make sure that the blogroll.js script is loaded, adding defer so that it is executed once the page has finished loading:

<script src="blogroll.js" defer></script>

Then add any HTML element with the class blogroll. The script will then build a simple unordered list element and add it as a child element:

<h3>Blogroll</h3>
<p class="blogroll" data-max-items="2" data-blogroll-file="blogroll-data.json"></p>

To customise the number of items to show at a single time, you can change the data-max-items of the associated element. If this is not set, 5 will be used as a default value.

And of course, you will need to provide the location of the blogroll JSON data file. This should be provided via a data-blogroll-file attribute.

If you want some basic styling, you can start here:

/* blogroll.js basic style */

.blogroll ul {
  list-style: none;
  padding-inline-start: 0;
}

.blogroll ul li a {
  text-decoration: wavy underline;
}

blogroll.js's People

Contributors

chrishannah avatar

Watchers

 avatar  avatar

Forkers

twhite96

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.