Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
Update for Hexo 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
timnew committed Apr 13, 2016
1 parent 0269c17 commit 80486da
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 112 deletions.
40 changes: 0 additions & 40 deletions gulpfile.coffee

This file was deleted.

48 changes: 15 additions & 33 deletions lib/index.js
@@ -1,33 +1,15 @@
(function() {
var codepenTagRender, htmlTag;

htmlTag = hexo.util.html_tag;

codepenTagRender = function(args, content) {
var defaultTab, height, params, slugHash, theme, url, userId, width, _ref, _ref1, _ref2;
userId = args[0] === 'anonymous' ? 'anon' : args[0];
slugHash = args[1];
theme = args[2];
defaultTab = (_ref = args[3]) != null ? _ref : 'result';
height = (_ref1 = args[4]) != null ? _ref1 : 300;
width = (_ref2 = args[5]) != null ? _ref2 : '100%';
url = "//codepen.io/" + userId + "/embed/" + slugHash + "?height=" + height + "&theme-id=" + theme + "&slug-hash=" + slugHash + "&default-tab=" + defaultTab;
params = {
id: "cp_embed_" + (slugHash.replace("/", "_")),
src: url,
scrolling: "no",
frameborder: "0",
height: height,
allowTransparency: "true",
allowfullscreen: "true",
"class": "cp_embed_iframe",
style: "width: " + width + "; overflow: hidden;"
};
return htmlTag('iframe', params, '');
};

hexo.extend.tag.register('codepen', codepenTagRender);

module.exports = codepenTagRender;

}).call(this);
// {% codepen userId|anonymous|anon slugHash theme [defaultTab [height [width]]] %}
function codepenTagRender(args) {
const userId = args[0] === 'anonymous' ? 'anon' : args[0];
const slugHash = args[1];
const theme = args[2];
const defaultTab = args[3] != null ? args[3] : 'result';
const height = args[4] != null ? args[4] : 300;
const width = args[5] != null ? args[5] : '100%';
const src = `//codepen.io/${userId}/embed/${slugHash}?height=${height}&theme-id=${theme}&slug-hash=${slugHash}&default-tab=${defaultTab}`;
const id = `cp_embed_${slugHash.replace(/\//g, '_')}`

return `<iframe id=${id} src=${src} scrolling="no" frameborder="no" height="${height}" allowTransparency="true" allowfullscreen="true" class="cp_embed_iframe" style=""width: ${width}; overflow: hidden;></iframe>`;
}

hexo.extend.tag.register('codpen', codepenTagRender);
29 changes: 0 additions & 29 deletions lib_src/index.coffee

This file was deleted.

12 changes: 2 additions & 10 deletions package.json
@@ -1,16 +1,8 @@
{
"name": "hexo-tag-codepen",
"version": "0.1.2",
"version": "0.2.0",
"description": "Hexo tag to embed code snippet from codepen.io",
"main": "index.js",
"devDependencies": {
"del": "^0.1.2",
"gulp": "^3.8.7",
"gulp-bump": "^0.1.11",
"gulp-coffee": "^2.1.1",
"yargs": "^1.3.1",
"coffee-script": "^1.7.1"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand All @@ -25,7 +17,7 @@
"codepen",
"timnew"
],
"author": "timnew <timnew.wti@gmail.com> (https://timnew.github.io/)",
"author": "timnew <timnewcnyn@gmail.com> (https://timnew.me/)",
"license": "MIT",
"bugs": {
"url": "https://github.com/timnew/hexo-tag-codepen/issues"
Expand Down

0 comments on commit 80486da

Please sign in to comment.