| i18n/en.toml | ●●●●● patch | view | raw | blame | history | |
| tests/fixtures/reading-time/content/posts/long.md | ●●●●● patch | view | raw | blame | history | |
| tests/fixtures/reading-time/content/posts/short.md | ●●●●● patch | view | raw | blame | history | |
| tests/fixtures/reading-time/hugo.toml | ●●●●● patch | view | raw | blame | history | |
| tests/fixtures/reading-time/reading-time.test.mjs | ●●●●● patch | view | raw | blame | history |
i18n/en.toml
@@ -45,7 +45,7 @@ [readingTime] one = "One minute read" other = "{{ .Count }} minutes read" other = "{{ .Count }} minute read" [wordCount] one = "One word" tests/fixtures/reading-time/content/posts/long.md
New file @@ -0,0 +1,5 @@ --- title: Long post --- word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word tests/fixtures/reading-time/content/posts/short.md
New file @@ -0,0 +1,5 @@ --- title: Short post --- Word. tests/fixtures/reading-time/hugo.toml
New file @@ -0,0 +1,6 @@ title = "Reading time fixture" theme = "ananke" [params] show_reading_time = true reading_speed = 100 # words per minute, so the fixture word counts give exact minutes tests/fixtures/reading-time/reading-time.test.mjs
New file @@ -0,0 +1,23 @@ import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import { test } from "node:test"; import { fileURLToPath } from "node:url"; import { load } from "cheerio"; import { buildFixtureSite } from "../../support/prepare-site.mjs"; const source = dirname(fileURLToPath(import.meta.url)); function readingTime(output, path) { const $ = load(readFileSync(join(output, path), "utf8")); return $("article header span.f6.tracked").first().text().trim(); } test("reading time uses the singular unit as a compound adjective (#870)", () => { const output = buildFixtureSite({ source }); assert.equal( readingTime(output, "posts/short/index.html"), "- One minute read", ); assert.equal(readingTime(output, "posts/long/index.html"), "- 3 minute read"); });