HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<div id="app">
<section id="updates">
<h1>What is Joe up to?</h1>
<p>Below is a "super feed" of what I'm up to, online. It is sorted by the date when I posted it. The <a href="https://travels.jws.app/"><i class="fal fa-hiking" title="Travel"></i> Joe Travels</a> posts are always from the back catalog, so the date is on each post.</p>
<ul>
<li v-for="update in updates">
<span v-if="update.showdate" style="font-weight: bold;">
{{update.published.toLocaleDateString("en-US", { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })}}
</span>
<div style="margin-left: 20px;">
<p><i v-bind:class="update.icon"></i> <a v-bind:href="update.url">{{update.title}}</a></p>
<!-- <p><img style="height: 10%;" v-bind:src="update.imgurl"></p> -->
</div>
</li>
</ul>
</section>
</div>
new Vue({
el: "#app",
data() {
return {
featimgposts: null,
featimages: [],
imgposts: null,
images: [],
blogposts: null,
github: null,
dev: null,
travels: null,
flies: null,
travelimages: [],
flightimages: [],
updates: []
};
},
watch: {
// Watch for the value of featimgposts to change
'featimgposts': function() {
// Track the array size for UI purposes
this.arraySize = this.featimgposts.length;
// Once featimgposts gets updated, this gets executed
for (var i = 0; i < this.arraySize; i++) {
var x = this.featimgposts[i].content.indexOf("href=\"");
var y = this.featimgposts[i].content.indexOf("\"",x+6);
this.featimages.push(this.featimgposts[i].content.substring(x+6,y));
}
},
// Watch for the value of imgposts to change
'imgposts': function() {
// Track the array size for UI purposes
this.arraySize = this.imgposts.length;
// Once imgposts gets updated, this gets executed
for (var i = 0; i < this.arraySize; i++) {
var x = this.imgposts[i].content.indexOf("href=\"");
var y = this.imgposts[i].content.indexOf("\"",x+6);
this.images.push(this.imgposts[i].content.substring(x+6,y));
this.imgposts[i].imgurl=this.imgposts[i].content.substring(x+6,y);
}
this.buildUpdates();
},
// Watch for the value of blogposts to change
'blogposts': function() {
this.buildUpdates();
},
// Watch for the value of github to change
'github': function() {
this.buildUpdates();
},
// Watch for the value of dev to change
'dev': function() {
this.buildUpdates();
},
// Watch for the value of travels to change
'travels': function() {
// Track the array size for UI purposes
this.arraySize = this.travels.length;
// Once travelimages gets updated, this gets executed
for (var i = 0; i < this.arraySize; i++) {
var x = this.travels[i].body.indexOf("src=\"");
var y = this.travels[i].body.indexOf("\"",x+5);
this.travelimages.push(this.travels[i].body.substring(x+5,y));
}
this.buildUpdates();
},
// Watch for the value of flies to change
'flies': function() {
// Track the array size for UI purposes
this.arraySize = this.flies.length;
// Once flightimages gets updated, this gets executed
for (var i = 0; i < this.arraySize; i++) {
var x = this.flies[i].body.indexOf("src=\"");
var y = this.flies[i].body.indexOf("\"",x+5);
this.flightimages.push(this.flies[i].body.substring(x+5,y));
}
this.buildUpdates();
}
},
methods: {
oneMonthAgo () {
var d = new Date();
var m = d.getMonth();
d.setMonth(d.getMonth() - 1);
// If still in same month, set date to last day of
// previous month
if (d.getMonth() == m) d.setDate(0);
d.setHours(0, 0, 0);
d.setMilliseconds(0);
// Get the time value in milliseconds and convert to seconds
return new Date(d);
},
buildUpdates () {
this.loaded=0;
if(typeof(this.imgposts) !== "undefined" && this.imgposts !== null){
// If there are blogger posts, add them to the updates array
this.loaded=this.loaded+1;
};
if(typeof(this.blogposts) !== "undefined" && this.blogposts !== null){
// If there are wordpress posts, add them to the updates array
this.loaded=this.loaded+1;
};
if(typeof(this.github) !== "undefined" && this.github !== null){
// If there is github activity, add them to the updates array
this.loaded=this.loaded+1;
};
if(typeof(this.dev) !== "undefined" && this.dev !== null){
// If there is practical dev activity, add them to the updates array
this.loaded=this.loaded+1;
console.log(this.dev);
};
if(typeof(this.travels) !== "undefined" && this.travels !== null){
// If there are "Joe Travels" posts, add them to the updates array
this.loaded=this.loaded+1;
};
if(typeof(this.flies) !== "undefined" && this.flies !== null){
// If there are "Joe Flies" posts, add them to the updates array
this.loaded=this.loaded+1;
};
// Do we have data from all 6 APIs?
if(this.loaded==6){
// Add recent images from the image blog
for (var i = 0; i < this.imgposts.length; i++) {
if(new Date(this.imgposts[i].published) >= this.oneMonthAgo())
this.updates.push({ icon: 'fal fa-photo-video', published: new Date(this.imgposts[i].published), title: this.imgposts[i].title, url: this.imgposts[i].url, imgurl: this.images[i], showdate: true });
}
// Add recent blog posts from the wordpress site
for (var i = 0; i < this.blogposts.length; i++) {
if(new Date(this.blogposts[i].date) >= this.oneMonthAgo())
this.updates.push({ icon: 'fal fa-blog', published: new Date(this.blogposts[i].date), title: this.blogposts[i].title.rendered, url: this.blogposts[i].link, imgurl: this.blogposts[i].jetpack_featured_media_url, showdate: true });
}
// Add recent github activity from github
for (var i = 0; i < 10; i++) {
if(new Date(this.github[i].created_at) >= this.oneMonthAgo())
this.updates.push({ icon: 'fab fa-github', published: new Date(this.github[i].created_at), title: this.github[i].type+': '+this.github[i].repo.name, url: this.github[i].repo.url, imgurl: './img/github.png', showdate: true });
}
// Add recent posts from the practical dev
for (var i = 0; i < this.dev.length; i++) {
if(new Date(this.dev[i].published_at) >= this.oneMonthAgo())
this.updates.push({ icon: 'fab fa-dev', published: new Date(this.dev[i].published_timestamp), title: this.dev[i].title, url: this.dev[i].url, imgurl: this.dev[i].social_image, showdate: true });
}
// Add recent images from the "Joe Travels" blog
for (var i = 0; i < 10; i++) {
if(new Date(this.travels[i].date) >= this.oneMonthAgo())
this.updates.push({ icon: 'fal fa-hiking', published: new Date(this.travels[i].date), title: this.travels[i].summary, url: this.travels[i].post_url, imgurl: this.travelimages[i], showdate: true });
}
// Add recent images from the "Joe Flies" blog
for (var i = 0; i < 10; i++) {
if(this.flies.length > i+1){
if(new Date(this.flies[i].date) >= this.oneMonthAgo())
this.updates.push({ icon: 'fal fa-drone-alt', published: new Date(this.flies[i].date), title: this.flies[i].summary, url: this.flies[i].post_url, imgurl: this.flightimages[i], showdate: true });
}
}
};
// Sort updates by date (descending)
this.updates.sort(function(a, b) {
return b.published - a.published;
});
// Set the "don't show the date" flag for when it's displayed on the screen
for (var i = 0; i < this.updates.length; i++) {
if(i>0 && this.updates[i].published.toLocaleDateString("en-US") == this.updates[i-1].published.toLocaleDateString("en-US")){
this.updates[i].showdate = false;
}
};
}
},
mounted() {
// Get the featured image posts from the blogger site
// this requires an API key
axios
.get("https://www.googleapis.com/blogger/v3/blogs/3412726727067752443/posts/search?q=label:fp&key=AIzaSyDMDCj74G_V9RzYRUXvQLsK2AWcob7FsKw")
.then(response=> (this.featimgposts = response.data.items));
// Get all image posts from the blogger site
// this requires an API key
axios
.get("https://www.googleapis.com/blogger/v3/blogs/3412726727067752443/posts/search?key=AIzaSyDMDCj74G_V9RzYRUXvQLsK2AWcob7FsKw")
.then(response=> (this.imgposts = response.data.items));
// Get posts from the wordpress blog
axios
.get("https://blog.jws.app/wp-json/wp/v2/posts")
.then(response=> (this.blogposts = response.data));
// Get github commits
axios
.get("https://api.github.com/users/steinbring/events")
.then(response=> (this.github = response.data));
// Get dev posts
axios
.get("https://dev.to/api/articles?username=steinbring")
.then(response=> (this.dev = response.data));
// Get travels.jws.app posts
axios
.get("https://api.tumblr.com/v2/blog/travels.jws.app/posts?api_key=vBP9f1qX2rROLMtFcjCRTIfleb0HOcArIs9Ui62oidzQItV63m")
.then(response=> (this.travels = response.data.response.posts));
// Get flies.jws.app posts
axios
.get("https://api.tumblr.com/v2/blog/flies.jws.app/posts?api_key=vBP9f1qX2rROLMtFcjCRTIfleb0HOcArIs9Ui62oidzQItV63m")
.then(response=> (this.flies = response.data.response.posts));
}
});
Also see: Tab Triggers