Skip to content

Commit

Permalink
new version
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Jul 17, 2023
1 parent 7f06f83 commit 38adf7a
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this
project adheres to [Semantic Versioning](http://semver.org/).

## [0.9.0] - 2023-07-17
- Allow to configure `date` plugin.
- New `_data/i18n.yml` file to customize or translate the static copies.

## [0.8.0] - 2023-07-07
### Changed
- Switch to Vento (from Nunjuks) as the template engine.
Expand Down Expand Up @@ -116,6 +120,7 @@ First version
[#1]: https://github.com/lumeland/theme-simple-blog/issues/1
[#5]: https://github.com/lumeland/theme-simple-blog/issues/5

[0.9.0]: https://github.com/lumeland/theme-simple-blog/compare/v0.8.0...v0.9.0
[0.8.0]: https://github.com/lumeland/theme-simple-blog/compare/v0.7.2...v0.8.0
[0.7.2]: https://github.com/lumeland/theme-simple-blog/compare/v0.7.1...v0.7.2
[0.7.1]: https://github.com/lumeland/theme-simple-blog/compare/v0.7.0...v0.7.1
Expand Down
8 changes: 7 additions & 1 deletion demo/_config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import lume from "lume/mod.ts";
import blog from "../mod.ts";
import gl from "npm:date-fns/locale/gl/index.js";

const site = lume();
site.use(blog());

site.use(blog({
date: {
locales: { gl },
},
}));

export default site;
17 changes: 17 additions & 0 deletions demo/_data/i18n.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
nav:
toc: Tabla de contidos
next_post: Post recente →
previous_post: ← Post antigo
continue_reading: Continuar lendo →
archive: Podes atopar máis posts <a href="/archive/">no arquivo</a>.
back: ← Atrás
page: Páxina
next: Seguinte →
previous: ← Anterior
post:
by: por
reading_time: min de lectura
search:
by_author: Posts escritos por
by_tag: Etiquetados como
tags: Etiquetas
1 change: 1 addition & 0 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function (options: Partial<Options> = {}) {
"fonts/epilogue-bold.woff2",
"posts/_data.yml",
"_data.yml",
"_data/i18n.yml",
"404.md",
"archive_result.tmpl.js",
"archive.tmpl.js",
Expand Down
5 changes: 3 additions & 2 deletions plugins.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import date from "lume/plugins/date.ts";
import date, { Options as DateOptions } from "lume/plugins/date.ts";
import postcss from "lume/plugins/postcss.ts";
import terser from "lume/plugins/terser.ts";
import prism, { Options as PrismOptions } from "lume/plugins/prism.ts";
Expand All @@ -18,6 +18,7 @@ import type { Page, Site } from "lume/core.ts";

export interface Options {
prism?: Partial<PrismOptions>;
date?: Partial<DateOptions>;
}

/** Configure the site */
Expand All @@ -28,7 +29,7 @@ export default function (options: Options = {}) {
.use(toc())
.use(prism(options.prism))
.use(readingTime())
.use(date())
.use(date(options.date))
.use(metas())
.use(image())
.use(resolveUrls())
Expand Down
17 changes: 17 additions & 0 deletions src/_data/i18n.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
nav:
toc: Table of Contents
next_post: Newer post →
previous_post: ← Older post
continue_reading: Continue reading →
archive: More posts can be found in <a href="/archive/">the archive</a>.
back: ← Back
page: Page
next: Next →
previous: ← Previous
post:
by: by
reading_time: min read
search:
by_author: Posts by
by_tag: Tagged
tags: Tags
8 changes: 4 additions & 4 deletions src/_includes/layouts/archive.vto
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ bodyClass: body-tag
{{ set pageTags = search.pages("type=tag", "tag") }}
{{ if pageTags.length }}
<nav class="page-navigation">
<h2>Tags:</h2>
<h2>{{ i18n.search.tags }}:</h2>

<ul class="page-navigation-tags">
{{ for page of pageTags }}
Expand All @@ -37,17 +37,17 @@ bodyClass: body-tag
<ul>
{{- if pagination.previous }}
<li class="pagination-prev">
<a href="{{ pagination.previous }}" rel="prev">← Previous</a>
<a href="{{ pagination.previous }}" rel="prev">{{ i18n.nav.previous }}</a>
</li>
{{ /if }}

<li class="pagination-page">
Page {{ pagination.page }}
{{ i18n.nav.page }} {{ pagination.page }}
</li>

{{- if pagination.next }}
<li class="pagination-next">
<a href="{{ pagination.next }}" rel="next">Next →</a>
<a href="{{ pagination.next }}" rel="next">{{ i18n.nav.next }}</a>
</li>
{{ /if }}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion src/_includes/layouts/archive_result.vto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ layout: layouts/base.vto
bodyClass: body-tag
---
<header class="page-header">
<p><a href="/archive/">← Back</a></p>
<p><a href="/archive/">{{ i18n.nav.back }}</a></p>
<h1 class="page-title">{{ title }}</h1>
</header>

Expand Down
4 changes: 2 additions & 2 deletions src/_includes/layouts/post.vto
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bodyClass: body-post
{{- if previousPost }}
<li class="pagination-prev">
<a href="{{ previousPost.data.url }}" rel="prev">
<span>← Older post</span>
<span>{{ i18n.nav.previous_post }}</span>
<strong>{{ previousPost.data.title }}</strong>
</a>
</li>
Expand All @@ -53,7 +53,7 @@ bodyClass: body-post
{{- if nextPost }}
<li class="pagination-next">
<a href="{{ nextPost.data.url }}" rel="next">
<span>Newer post →</span>
<span>{{ i18n.nav.next_post }}</span>
<strong>{{ nextPost.data.title }}</strong>
</a>
</li>
Expand Down
10 changes: 5 additions & 5 deletions src/_includes/templates/post-details.vto
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<div class="post-details">
{{# {{ if author }}
{{ if author }}
{{ set page = search.page(`type=author author="author"`) }}
{{ if page }}
<p>By <a data-pagefind-filter="author" href="{{ page.data.url }}">{{ author }}</a></p>
<p>{{ i18n.post.by}} <a data-pagefind-filter="author" href="{{ page.data.url }}">{{ author }}</a></p>
{{ else }}
<p>By {{ author }}</p>
<p>{{ i18n.post.by}} {{ author }}</p>
{{ /if }}
{{ /if }} #}}
{{ /if }}

<p>
<time datetime="{{ date |> date('DATETIME') }}">
{{ date |> date('HUMAN_DATE') }}
</time>
</p>

<p>{{ readingTime.minutes }} min read</p>
<p>{{ readingTime.minutes }} {{ i18n.post.reading_time}}</p>

<div class="post-tagsss">
{{ for tag of tags }}
Expand Down
6 changes: 3 additions & 3 deletions src/archive_result.tmpl.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export const layout = "layouts/archive_result.vto";

export default function* ({ search }) {
export default function* ({ search, i18n }) {
// Generate a page for each tag
for (const tag of search.values("tags")) {
yield {
url: `/archive/${tag}/`,
title: `Tagged${tag}”`,
title: `${i18n.search.by_tag} ${tag}”`,
type: "tag",
search_query: `type=post '${tag}'`,
tag,
Expand All @@ -16,7 +16,7 @@ export default function* ({ search }) {
for (const author of search.values("author")) {
yield {
url: `/author/${author}/`,
title: `Posts by ${author}`,
title: `${i18n.search.by_author} ${author}`,
type: "author",
search_query: `type=post author='${author}'`,
author,
Expand Down
4 changes: 2 additions & 2 deletions src/index.vto
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ title: Home
</div>

<a href="{{ post.data.url }}" class="post-link">
Continue reading →
{{ i18n.nav.continue_reading }}
</a>
</article>
{{ /for }}
</section>

<hr>

<p>More posts can be found in <a href="/archive/">the archive</a>.</p>
<p>{{ i18n.nav.archive }}</p>

0 comments on commit 38adf7a

Please sign in to comment.