Skip to content

Commit

Permalink
bring in generic updates from my personal instance
Browse files Browse the repository at this point in the history
  • Loading branch information
top-ghost committed Sep 21, 2024
1 parent 80d8df5 commit cd5f4b6
Show file tree
Hide file tree
Showing 26 changed files with 118 additions and 241 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
## Github repo setup

1. At the top of this repo, click on the "Use this template" dropdown and choose "Create a new repository". Give the repo a name and make note of the resulting HTTPS URL: it should look something like `https://github.com/${your username}/${the repo name}`. You'll be collecting more things in your notes to go along with this.
2. Edit the \_data/metadata.js file to set up the website's metadata. This is used in things like the RSS feed / page template OpenGraph tags. If you don't change these, things WILL look broken/silly to people who see your site elsewhere on the web.
3. You probably should go into the `content/` directory and remove the `intro.md` file. You can do that whenever you like though!

## GitHub app setup

Expand Down
8 changes: 5 additions & 3 deletions _data/metadata.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// NOTE: you really should override _all_ of these fields!
// ...except maybe the language one if you're mostly writing in English I suppose
module.exports = {
title: "Eleventy Base Blog v8",
url: "https://example.com/",
title: "Octobug Template",
url: "https://github.com/top-ghost/octobug",
language: "en",
description: "I am writing about my experiences as a naval navel-gazer.",
description: "Just setting up my Octobug",
author: {
name: "Your Name Here",
email: "[email protected]",
Expand Down
13 changes: 1 addition & 12 deletions _includes/layouts/home.njk
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
---
layout: layouts/base.njk
---
<!-- Delete this message, it will also remove the component CSS from the bundle -->
{%- css %}{% include "public/css/message-box.css" %}{% endcss %}
<div class="message-box">
<ol>
<li>Edit the <code>_data/metadata.js</code> with your blog’s information.</li>
<li>(Optional) Edit <code>eleventy.config.js</code> with your <a href="https://www.11ty.dev/docs/config/">configuration preferences</a>.</li>
<li>Delete this message from <code>_includes/layouts/home.njk</code>.</li>
</ol>
<p><em>This is an <a href="https://www.11ty.dev/">Eleventy project</a> created from the <a href="https://github.com/11ty/eleventy-base-blog"><code>eleventy-base-blog</code> repo</a>.</em></p>
</div>
<!-- Stop deleting -->

{{ content | safe }}
{{ content | safe }}
22 changes: 1 addition & 21 deletions _includes/layouts/post.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,5 @@ layout: layouts/base.njk
{# Only include the syntax highlighter CSS on blog posts #}
{%- css %}{% include "node_modules/prismjs/themes/prism-okaidia.css" %}{% endcss %}
{%- css %}{% include "public/css/prism-diff.css" %}{%- endcss %}
<h1>{{ title }}</h1>

<ul class="post-metadata">
<li><time datetime="{{ page.date | htmlDateString }}">{{ page.date | readableDate }}</time></li>
{%- for tag in tags | filterTagList %}
{%- set tagUrl %}/tags/{{ tag | slugify }}/{% endset %}
<li><a href="{{ tagUrl }}" class="post-tag">{{ tag }}</a>{%- if not loop.last %}, {% endif %}</li>
{%- endfor %}
</ul>

{{ content | safe }}

{%- if collections.posts %}
{%- set previousPost = collections.posts | getPreviousCollectionItem %}
{%- set nextPost = collections.posts | getNextCollectionItem %}
{%- if nextPost or previousPost %}
<ul class="links-nextprev">
{%- if previousPost %}<li>Previous: <a href="{{ previousPost.url }}">{{ previousPost.data.title }}</a></li>{% endif %}
{%- if nextPost %}<li>Next: <a href="{{ nextPost.url }}">{{ nextPost.data.title }}</a></li>{% endif %}
</ul>
{%- endif %}
{%- endif %}
{% include "../partials/post.njk" %}
20 changes: 20 additions & 0 deletions _includes/partials/post.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{%set item = post | d(collections.all | getCollectionItem(page))%}

<div class="post">
<div class="metadata">
<div class="author">{{item.data.author}}</div>
<div class="timestamp">{{item.data.timestamp}}</div>
</div>
<a href={{item.url}}>
<h1 class="title">{{item.data.title}}</h1>
</a>
<div class="postbody">{{item.content | safe }}</div>
<div class="tags">
{%- for tag in item.tags | filterTagList %}{%- set tagUrl %}/tags/{{ tag | slugify }}/{% endset %}
<li>
<a href="{{ tagUrl }}" class="post-tag">{{ tag }}</a>
{%- if not loop.last %}, {% endif %}
</li>
{%- endfor %}
</div>
</div>
11 changes: 4 additions & 7 deletions _includes/postslist.njk
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{%- css %}.postlist { counter-reset: start-from {{ (postslistCounter or postslist.length) + 1 }} }{% endcss %}
<ol reversed class="postlist">
{% for post in postslist | reverse %}
<li class="postlist-item{% if post.url == url %} postlist-item-active{% endif %}">
<a href="{{ post.url }}" class="postlist-link">{% if post.data.title %}{{ post.data.title }}{% else %}<code>{{ post.url }}</code>{% endif %}</a>
<time class="postlist-date" datetime="{{ post.date | htmlDateString }}">{{ post.date | readableDate("LLLL yyyy") }}</time>
</li>
{% endfor %}
</ol>
{% for post in postslist | reverse %}
{% include "partials/post.njk" %}
{% endfor %}
</ol>
9 changes: 0 additions & 9 deletions content/about/index.md

This file was deleted.

10 changes: 0 additions & 10 deletions content/blog.njk

This file was deleted.

6 changes: 0 additions & 6 deletions content/blog/blog.11tydata.js

This file was deleted.

6 changes: 0 additions & 6 deletions content/blog/fifthpost.md

This file was deleted.

26 changes: 0 additions & 26 deletions content/blog/firstpost.md

This file was deleted.

16 changes: 0 additions & 16 deletions content/blog/fourthpost/fourthpost.md

This file was deleted.

Binary file removed content/blog/fourthpost/possum.png
Binary file not shown.
17 changes: 0 additions & 17 deletions content/blog/secondpost.md

This file was deleted.

45 changes: 0 additions & 45 deletions content/blog/thirdpost.md

This file was deleted.

22 changes: 11 additions & 11 deletions content/feed/feed.njk
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ permalink: /feed/feed.xml
<subtitle>{{ metadata.description }}</subtitle>
<link href="{{ permalink | htmlBaseUrl(metadata.url) }}" rel="self"/>
<link href="{{ metadata.url | addPathPrefixToFullUrl }}"/>
<updated>{{ collections.posts | getNewestCollectionItemDate | dateToRfc3339 }}</updated>
<updated>{{ collections.all | getNewestCollectionItemDate | dateToRfc3339 }}</updated>
<id>{{ metadata.url }}</id>
<author>
<name>{{ metadata.author.name }}</name>
<email>{{ metadata.author.email }}</email>
</author>
{%- for post in collections.posts | reverse %}
{% set absolutePostUrl %}{{ post.url | htmlBaseUrl(metadata.url) }}{% endset %}
<entry>
<title>{{ post.data.title }}</title>
<link href="{{ absolutePostUrl }}"/>
<updated>{{ post.date | dateToRfc3339 }}</updated>
<id>{{ absolutePostUrl }}</id>
<content type="html">{{ post.templateContent | transformWithHtmlBase(absolutePostUrl, post.url) }}</content>
</entry>
{%- for post in collections.all | reverse %}
{% set absolutePostUrl %}{{ post.url | htmlBaseUrl(metadata.url) }}{% endset %}
<entry>
<title>{{ post.data.title }}</title>
<link href="{{ absolutePostUrl }}"/>
<updated>{{ post.date | dateToRfc3339 }}</updated>
<id>{{ absolutePostUrl }}</id>
<content type="html">{{ post.templateContent | transformWithHtmlBase(absolutePostUrl, post.url) }}</content>
</entry>
{%- endfor %}
</feed>
</feed>
11 changes: 6 additions & 5 deletions content/feed/json.njk
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ permalink: /feed/feed.json
"url": "{{ metadata.author.url }}"
},
"items": [
{%- for post in collections.posts | reverse %}
{%- set absolutePostUrl = post.url | htmlBaseUrl(metadata.url) %}
{%- for post in collections.all | reverse %}
{%- set absolutePostUrl = post.url | htmlBaseUrl(metadata.url) %}
{
"id": "{{ absolutePostUrl }}",
"url": "{{ absolutePostUrl }}",
"title": "{{ post.data.title }}",
"content_html": {% if post.templateContent %}{{ post.templateContent | transformWithHtmlBase(absolutePostUrl, post.url) | dump | safe }}{% else %}""{% endif %},
"content_html": {% if post.templateContent %}{{ post.templateContent | transformWithHtmlBase(absolutePostUrl, post.url) | dump | safe }}
{% else %}""{% endif %},
"date_published": "{{ post.date | dateToRfc3339 }}"
}
{% if not loop.last %},{% endif %}
{%- endfor %}
]
{%- endfor %}
]
}
40 changes: 18 additions & 22 deletions content/index.njk
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
---
layout: layouts/home.njk
eleventyNavigation:
key: Home
order: 1
numberOfLatestPostsToShow: 3
eleventyExcludeFromCollections: true
pagination:
data: collections.all
size: 10
permalink: "/{% if pagination.pageNumber > 0 %}/{{ pagination.pageNumber }}{% endif %}/index.html"
---
{% set postsCount = collections.posts | length %}
{% set latestPostsCount = postsCount | min(numberOfLatestPostsToShow) %}
<h1>Latest {{ latestPostsCount }} Post{% if latestPostsCount != 1 %}s{% endif %}</h1>

{% set postslist = collections.posts | head(-1 * numberOfLatestPostsToShow) %}
{% set postslistCounter = postsCount %}
{%set postslist = pagination.items %}
{% include "postslist.njk" %}

{% set morePosts = postsCount - numberOfLatestPostsToShow %}
{% if morePosts > 0 %}
<p>{{ morePosts }} more post{% if morePosts != 1 %}s{% endif %} can be found in <a href="/blog/">the archive</a>.</p>
{% endif %}

{# List every content page in the project #}
{#
<ul>
{%- for entry in collections.all %}
<li><a href="{{ entry.url }}"><code>{{ entry.url }}</code></a></li>
{%- endfor %}
</ul>
#}
<ol>
<li>
{% if pagination.href.previous %}
<a href="{{ pagination.href.previous }}">Previous</a>
{% else %}Previous{% endif %}
</li>
<li>
{% if pagination.href.next %}
<a href="{{ pagination.href.next }}">Next</a>
{% else %}Next{% endif %}
</li>
</ol>
7 changes: 7 additions & 0 deletions content/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---json
{"author":"@topghost","date":"git Created","title":"oh hello","timestamp":1726960359167,"tags":["octobug meta"],"layout":"layouts/post.njk"}
---

You've come across the generated site for Octobug, an Eleventy-based GitHub-hosted blogging tool. You should probably go read about it on [its GitHub repo](https://github.com/top-ghost/octobug) instead.

Bye!
13 changes: 8 additions & 5 deletions content/tags-list.njk
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
---
permalink: /tags/
layout: layouts/home.njk
eleventyExcludeFromCollections: true
---
<h1>Tags</h1>

<ul>
{% for tag in collections.all | getAllTags | filterTagList %}
{% set tagUrl %}/tags/{{ tag | slugify }}/{% endset %}
<li><a href="{{ tagUrl }}" class="post-tag">{{ tag }}</a></li>
{% endfor %}
</ul>
{% for tag in collections.all | getAllTags | filterTagList %}
{% set tagUrl %}/tags/{{ tag | slugify }}/{% endset %}
<li>
<a href="{{ tagUrl }}" class="post-tag">{{ tag }}</a>
</li>
{% endfor %}
</ul>
Loading

0 comments on commit cd5f4b6

Please sign in to comment.