Skip to content

Commit b94911a

Browse files
committed
added blog & netlify.toml
1 parent 8e4d740 commit b94911a

21 files changed

+394
-24
lines changed

.eleventy.js

+17
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
const yaml = require("js-yaml");
2+
const { DateTime } = require("luxon");
3+
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
24

35
module.exports = function (eleventyConfig) {
46
// Disable automatic use of your .gitignore
57
eleventyConfig.setUseGitIgnore(false);
68

9+
// Merge data instead of overriding
10+
eleventyConfig.setDataDeepMerge(true);
11+
12+
// human readable date
13+
eleventyConfig.addFilter("readableDate", (dateObj) => {
14+
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat(
15+
"dd LLL yyyy"
16+
);
17+
});
18+
19+
// Syntax Highlighting for Code blocks
20+
eleventyConfig.addPlugin(syntaxHighlight);
21+
722
// To Support .yaml Extension in _data
823
// You may remove this if you can use JSON
924
eleventyConfig.addDataExtension("yaml", (contents) =>
@@ -18,6 +33,8 @@ module.exports = function (eleventyConfig) {
1833
"./_tmp/static/css/style.css": "./static/css/style.css",
1934
"./admin/config.yml": "./admin/config.yml",
2035
"./node_modules/alpinejs/dist/alpine.js": "./static/js/alpine.js",
36+
"./node_modules/prismjs/themes/prism-tomorrow.css":
37+
"./static/css/prism-tomorrow.css",
2138
});
2239

2340
// Copy Image Folder to /_site

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Starter Template for **N**etlify CMS, **E**leventy, **A**lphine JS & **T**ailwind CSS
44

5+
## Live Demo
6+
7+
[https://neat-starter.netlify.app/](https://neat-starter.netlify.app/)
8+
59
### Technologies used:
610

711
- [Netlify CMS](https://www.netlifycms.org/)

_data/navigation.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
items:
3-
- text: Products
3+
- text: Menu One
44
url: "#"
5-
- text: Features
5+
- text: Menu Two
66
url: "#"
7-
- text: Pricing
8-
url: "#"
9-
- text: Contact
7+
- text: Menu Three
108
url: "#"
9+
- text: Blog
10+
url: "/blog"

_includes/blog.njk

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Our Blog
3+
layout: default
4+
---
5+
6+
<div class="container max-w-3xl mt-6 px-6">
7+
8+
<h1 class="font-bold text-5xl">{{title}}</h1>
9+
10+
{{ content | safe }}
11+
12+
</div>

_includes/default.njk

+5
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@
1212
{% endif %}
1313
{% block head %}{% endblock %}
1414
<link rel="stylesheet" type="text/css" href="/static/css/style.css"/>
15+
{% if prism == true %}
16+
<link rel="stylesheet" type="text/css" href="/static/css/prism-tomorrow.css">
17+
{% endif %}
1518
</head>
1619
<body>
1720
{% include "partials/navbar.njk" %}
1821

1922
{{ content | safe }}
2023

24+
{% include "partials/footer.njk" %}
25+
2126
<script src="/static/js/alpine.js"></script>
2227

2328
</body>

_includes/partials/content.njk

+1-11
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,4 @@
1212

1313
{% endif %}
1414

15-
</div>
16-
17-
<footer class="fixed bottom-0 py-4">
18-
<small class="text-gray-500">Copyright ©
19-
{{settings.meta.name}}
20-
2020. Made with ❤ by
21-
<a href="{{settings.meta.url}}" target="_blank" class="underline">{{settings.meta.author}}</a>
22-
23-
<a href="https://github.com/surjithctly/neat-starter" class="underline" target="_blank" rel="noopener">View on Github</a>
24-
</small>
25-
</footer>
15+
</div>

_includes/partials/footer.njk

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<footer class="{{ 'fixed' if path == 'home' }} bottom-0 text-center py-4">
2+
<small class="text-gray-500">Copyright ©
3+
{{settings.name}}
4+
2020. Made with ❤ by
5+
<a href="{{settings.meta.url}}" target="_blank" class="underline">{{settings.author}}</a>
6+
7+
<a href="https://github.com/surjithctly/neat-starter" class="underline" target="_blank" rel="noopener">View on Github</a>
8+
</small>
9+
</footer>

_includes/partials/navbar.njk

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="lg:fixed w-full">
1+
<div class="{{ 'lg:fixed' if path == 'home' }} w-full">
22
<nav class="flex items-center justify-center lg:justify-between flex-wrap p-6 lg:px-0 container mx-auto" x-data="{ isOpen: false }" @keydown.escape="isOpen = false">
33
<!--Logo etc-->
44
<div class="flex items-center">

_includes/posts.njk

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
layout: default
3+
prism: true
4+
---
5+
6+
<div class="container max-w-4xl mt-6 px-6">
7+
<div class="pb-5 mb-5 border-b border-gray-100">
8+
<h1 class="font-bold text-5xl">{{title}}</h1>
9+
<p class="text-center text-base leading-6 font-medium text-gray-500">
10+
<time>
11+
{{ date | readableDate }}
12+
by
13+
<a>{{ author }}</a>
14+
15+
</time>
16+
</p>
17+
18+
</div>
19+
<article class="prose lg:prose-xl my-4 mx-auto">
20+
{{ content | safe }}</article>
21+
22+
</div>

admin/config.yml

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
11
backend:
2-
name: github
3-
repo: surjithctly/neat-starter
2+
# Use netlify identity as backend
3+
name: git-gateway
4+
branch: master
5+
### enable below lines for github integration ###
6+
# name: github
7+
# repo: surjithctly/neat-starter
48
media_folder: "static/img"
59
# Please run "npx netlify-cms-proxy-server" for local backend
610
local_backend: true
711
# publish_mode: editorial_workflow
812
collections:
13+
- label: "Blog"
14+
name: "blog"
15+
folder: "posts"
16+
create: true
17+
editor:
18+
preview: false
19+
fields:
20+
- { label: "Title", name: "title", widget: "string" }
21+
- { label: "Description", name: "description", widget: "string" }
22+
- { label: "Author", name: "author", widget: "string" }
23+
- { label: "Publish Date", name: "date", widget: "datetime" }
24+
- { label: "Body", name: "body", widget: "markdown" }
25+
- widget: select
26+
label: "tags"
27+
name: "tags"
28+
multiple: true
29+
create: true
30+
options: ["Tags", "created", "from", "config.yml"]
931
- label: "Settings"
1032
name: "settings"
1133
editor:

blog/index.njk

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
layout: blog
3+
---
4+
5+
<section class="mt-15">
6+
{% set postslist = collections.post %}
7+
8+
{% for post in postslist | reverse %}
9+
<article class="my-8">
10+
<h2 class="font-bold text-3xl text-gray-900 mb-2">
11+
<a href="{{ post.url | url }}">
12+
{% if post.data.title %}
13+
{{ post.data.title }}
14+
{% else %}
15+
Untitled
16+
{% endif %}
17+
</a>
18+
</h2>
19+
<p class="text-base leading-6 text-gray-500 mb-3">
20+
<time>
21+
{{ post.date | readableDate }}
22+
by
23+
<a>{{ post.data.author }}</a>
24+
25+
</time>
26+
</p>
27+
{% if post.data.description %}
28+
<p class="text-lg text-gray-500 mb-3">
29+
{{ post.data.description }}
30+
</p>
31+
{% endif %}
32+
33+
<p>
34+
<a href="{{ post.url | url }}" class="text-indigo-500 font-bold text-lg">
35+
Read more →
36+
</a>
37+
</p>
38+
39+
</article>
40+
{% endfor %}
41+
</section>

index.njk

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
layout: default
33
title: Neat Starter
4+
path: home
45
---
56

67
<div class="container mx-auto lg:h-screen flex flex-col justify-center items-center">
@@ -17,4 +18,6 @@ title: Neat Starter
1718

1819
{% include "_includes/partials/content.njk" %}
1920

21+
{% include "_includes/partials/footer.njk" %}
22+
2023
</div>

netlify.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build]
2+
publish = "_site"
3+
command = "npm run build"

package.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@
22
"scripts": {
33
"start": "npm-run-all --parallel css eleventy",
44
"eleventy": "eleventy --serve",
5+
"debug": "set DEBUG=* & eleventy",
56
"css": "postcss static/css/tailwind.css --o _tmp/static/css/style.css --watch",
67
"build": "cross-env NODE_ENV=production eleventy && cross-env NODE_ENV=production postcss static/css/tailwind.css --o _site/static/css/style.css"
78
},
89
"devDependencies": {
910
"@11ty/eleventy": "^0.11.0",
11+
"@11ty/eleventy-plugin-syntaxhighlight": "^3.0.1",
12+
"@tailwindcss/typography": "^0.2.0",
1013
"alpinejs": "^2.6.0",
1114
"cross-env": "^7.0.2",
15+
"js-yaml": "^3.14.0",
16+
"luxon": "^1.25.0",
1217
"npm-run-all": "^4.1.5",
1318
"postcss-clean": "^1.1.0",
1419
"postcss-cli": "^7.1.1",
20+
"prismjs": "^1.21.0",
1521
"tailwindcss": "^1.7.2"
16-
},
17-
"dependencies": {
18-
"js-yaml": "^3.14.0"
1922
}
20-
}
23+
}

posts/my-first-post.md

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: This is my first post
3+
description: Capitalize on low hanging fruit to identify a ballpark value added
4+
activity to beta test. Override the digital divide with additional
5+
clickthroughs from DevOps.
6+
date: 2020-09-01
7+
author: Surjith S M
8+
tags:
9+
- left
10+
- center
11+
- right
12+
---
13+
14+
# Markdown syntax guide
15+
16+
## Headers
17+
18+
# This is a Heading h1
19+
20+
## This is a Heading h2
21+
22+
###### This is a Heading h6
23+
24+
## Emphasis
25+
26+
_This text will be italic_
27+
_This will also be italic_
28+
29+
**This text will be bold**
30+
**This will also be bold**
31+
32+
_You **can** combine them_
33+
34+
## Lists
35+
36+
### Unordered
37+
38+
- Item 1
39+
- Item 2
40+
- Item 2a
41+
- Item 2b
42+
43+
### Ordered
44+
45+
1. Item 1
46+
1. Item 2
47+
1. Item 3
48+
1. Item 3a
49+
1. Item 3b
50+
51+
## Images
52+
53+
![This is a alt text.](/image/sample.png "This is a sample image.")
54+
55+
## Links
56+
57+
You may be using [Markdown Live Preview](https://markdownlivepreview.com/).
58+
59+
## Blockquotes
60+
61+
> Markdown is a lightweight markup language with plain-text-formatting syntax, created in 2004 by John Gruber with Aaron Swartz.
62+
>
63+
> > Markdown is often used to format readme files, for writing messages in online discussion forums, and to create rich text using a plain text editor.
64+
65+
## Inline code
66+
67+
This web site is using `markedjs/marked`.

0 commit comments

Comments
 (0)