-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bf68a4
commit b9d1507
Showing
7 changed files
with
694 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const { v4: uuidv4 } = require("uuid"); | ||
const { paramCase } = require("change-case"); | ||
|
||
const today = new Date(); | ||
|
||
const getYear = today.getFullYear(); | ||
const getMonth = today.getMonth() + 1; | ||
const getDay = today.getDate(); | ||
|
||
const padLeft = (num) => num < 10 ? "0" + num : "" + num; | ||
|
||
const getDate = `${getYear}-${padLeft(getMonth)}-${padLeft(getDay)}`; | ||
|
||
const IMAGE_PATH = "/_images/"; | ||
const DEFAULT_THUMB = IMAGE_PATH + "default-thumb.png"; | ||
|
||
module.exports = { | ||
helpers: { | ||
getPostFileName: (locals) => { | ||
if (locals.isDraft === "yes") { | ||
return `DRAFT-${locals.permalink ? locals.permalink : uuidv4() }`; | ||
} | ||
|
||
const permalink = locals.permalink || paramCase(locals.title); | ||
return `${getYear}/${getDate}-${permalink}`; | ||
}, | ||
getYear, | ||
IMAGE_PATH, | ||
DEFAULT_THUMB, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
to: input/pages/<%= h.changeCase.param(permalink || title) %>.md | ||
--- | ||
--- | ||
title: "<%= title %>" | ||
<% if (locals.meta_title) { -%> | ||
meta_title: "<%= meta_title %>" | ||
<% } -%> | ||
meta_description: "<%= meta_description || "TODO: Write a description" %>" | ||
featured_img: <%= featured_img ? `${h.IMAGE_PATH}${h.getYear}/${featured_img}` : h.DEFAULT_THUMB %> | ||
<% if (locals.canonical_link) { -%> | ||
canonical_link: <%= canonical_link %> | ||
<% } -%> | ||
--- | ||
|
||
Go forth 🙌 | ||
|
||
{% warning %}Warning panel{% endwarning %} | ||
|
||
{% info %}Info panel{% endinfo %} | ||
|
||
{% bigtext %}Big text{% endbigtext %} | ||
|
||
{% caption %}Caption text{% endcaption %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module.exports = [ | ||
{ | ||
type: 'input', | ||
name: 'title', | ||
message: "Page title" | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'permalink', | ||
message: "Page permalink" | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'meta_title', | ||
message: "Meta title" | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'meta_description', | ||
message: "Meta description" | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'featured_img', | ||
message: "Featured image file name" | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'canonical_link', | ||
message: "Canonical link" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
to: input/posts/<%= h.getPostFileName(locals) %>.md | ||
--- | ||
--- | ||
title: "<%= title || "TODO: Write an title" %>" | ||
<% if (locals.meta_title) { -%> | ||
meta_title: "<%= meta_title %>" | ||
<% } -%> | ||
excerpt: "<%= excerpt || "TODO: Write an excerpt" %>" | ||
<% if (locals.meta_description) { -%> | ||
meta_description: "<%= meta_description %>" | ||
<% } -%> | ||
featured_img: <%= featured_img ? `${h.IMAGE_PATH}${h.getYear}/${featured_img}` : h.DEFAULT_THUMB %> | ||
<% if (locals.tags.length) { -%> | ||
tags: ["<%- tags.join('\", \"') %>"] | ||
<% } -%> | ||
<% if (locals.link_to) { -%> | ||
link_to: <%= link_to %> | ||
<% } -%> | ||
<% if (locals.canonical_link) { -%> | ||
canonical_link: <%= canonical_link %> | ||
<% } -%> | ||
<% if (locals.isDraft === "yes") { -%> | ||
eleventyExcludeFromCollections: true | ||
<% } -%> | ||
--- | ||
|
||
Go forth 🙌 | ||
|
||
<img src="/_images/<%= h.getYear %>/featured_image.jpg" class="aligncenter" alt=""> | ||
{% caption %}Caption text{% endcaption %} | ||
|
||
{% warning %}Warning panel{% endwarning %} | ||
|
||
{% info %}Info panel{% endinfo %} | ||
|
||
{% bigtext %}Big text{% endbigtext %} | ||
|
||
{% h2br %}References{% endh2br %} | ||
|
||
- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
module.exports = [ | ||
{ | ||
type: 'select', | ||
name: 'isDraft', | ||
message: "Is this post a draft?", | ||
choices: ["yes", "no"] | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'permalink', | ||
message: "Post permalink" | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'title', | ||
message: "Post title" | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'meta_title', | ||
message: "Meta title" | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'excerpt', | ||
message: "Post excerpt" | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'meta_description', | ||
message: "Meta description" | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'featured_img', | ||
message: "Featured image file name" | ||
}, | ||
{ | ||
type: 'list', | ||
name: 'tags', | ||
message: "Enter tags, separated by commas" | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'link_to', | ||
message: "Link out" | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'canonical_link', | ||
message: "Canonical link" | ||
} | ||
] |
Oops, something went wrong.