diff --git a/README.md b/README.md index a4202b7..ddcd306 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,28 @@ Usage example: #### 4.1 `howlong` -Adds https://howlongtobeat.com/ game length (`MainGame`) and an ID to your front matter, provided you first added a property called `game_name`. (This gets substituted). +Adds https://howlongtobeat.com/ game length (`MainGame`) and an ID to your front matter (keys `howlongtobeat_id` and `howlongtobeat_hrs`), provided you first added a property called `game_name`. (This gets substituted). + +So, Frontmatter like this: + +``` +--- +title: Diablo 3 my Review +game_name: Diablo 3 +--- +``` + +Gets subsituted by something like this: + +``` +--- +title: Diablo 3 my Review +howlongtobeat_id: 62129 +howlongtobeat_hrs: 20.5 +--- +``` + +In your Hugo template, add a link to `https://howlongtobeat.com/game?id={howlongtobeat_id}` and you're all set! Usage example: diff --git a/src/goodreads-widgetify.js b/src/goodreads/widgetify.js similarity index 100% rename from src/goodreads-widgetify.js rename to src/goodreads/widgetify.js diff --git a/src/howlong-tobeat.js b/src/howlongtobeat/howlong.js similarity index 97% rename from src/howlong-tobeat.js rename to src/howlongtobeat/howlong.js index a8213d5..b1638de 100644 --- a/src/howlong-tobeat.js +++ b/src/howlongtobeat/howlong.js @@ -1,7 +1,7 @@ const hltb = require('howlongtobeat') const hltbService = new hltb.HowLongToBeatService() -const { getFiles } = require('./file-utils'); +const { getFiles } = require('./../file-utils'); const fs = require('fs').promises; const {promisify} = require('util'); diff --git a/src/index.js b/src/index.js index f3ed52a..5c65ce9 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ -const { parseMastoFeed } = require('./masto-feed-parser') -const { widgetify } = require('./goodreads-widgetify.js') -const { buildIndex } = require('./lunr-index-builder.js') -const { howlong } = require('./howlong-tobeat.js') +const { parseMastoFeed } = require('./mastodon/feed-parser') +const { widgetify } = require('./goodreads/widgetify.js') +const { buildIndex } = require('./lunr/index-builder.js') +const { howlong } = require('./howlongtobeat/howlong.js') module.exports = { mastodon: { diff --git a/src/lunr-index-builder.js b/src/lunr/index-builder.js similarity index 96% rename from src/lunr-index-builder.js rename to src/lunr/index-builder.js index 6b97d52..cb54f39 100644 --- a/src/lunr-index-builder.js +++ b/src/lunr/index-builder.js @@ -1,5 +1,5 @@ const fs = require('fs').promises; -const { getFiles } = require('./file-utils'); +const { getFiles } = require('./../file-utils'); const { promisify } = require('util'); const frontMatterParser = require('parser-front-matter'); diff --git a/src/masto-feed-parser.js b/src/mastodon/feed-parser.js similarity index 98% rename from src/masto-feed-parser.js rename to src/mastodon/feed-parser.js index 156cd30..b5b8bc9 100644 --- a/src/masto-feed-parser.js +++ b/src/mastodon/feed-parser.js @@ -2,7 +2,7 @@ const got = require("got"); const parser = require("fast-xml-parser"); const { writeFileSync, existsSync, mkdirSync } = require('fs'); const ent = require('ent') -const { getFiles } = require('./file-utils'); +const { getFiles } = require('./../file-utils'); const dayjs = require('dayjs') const utc = require('dayjs/plugin/utc') dayjs.extend(utc) diff --git a/test/goodreads-widgetify.test.js b/test/goodreads/widgetify.test.js similarity index 77% rename from test/goodreads-widgetify.test.js rename to test/goodreads/widgetify.test.js index 13abc72..0a3e75f 100644 --- a/test/goodreads-widgetify.test.js +++ b/test/goodreads/widgetify.test.js @@ -1,6 +1,6 @@ jest.mock('https') -const { widgetify } = require('../src/goodreads-widgetify') +const { widgetify } = require('../../src/goodreads/widgetify') test("goodreads-widgetify changes from lowres to hires images", async () => { const result = await widgetify("fake") diff --git a/test/__snapshots__/howlong-tobeat.test.js.snap b/test/howlongtobeat/__snapshots__/howlong.test.js.snap similarity index 100% rename from test/__snapshots__/howlong-tobeat.test.js.snap rename to test/howlongtobeat/__snapshots__/howlong.test.js.snap diff --git a/test/howlong-tobeat.test.js b/test/howlongtobeat/howlong.test.js similarity index 85% rename from test/howlong-tobeat.test.js rename to test/howlongtobeat/howlong.test.js index 88a897f..7936ad9 100644 --- a/test/howlong-tobeat.test.js +++ b/test/howlongtobeat/howlong.test.js @@ -1,9 +1,9 @@ jest.mock('howlongtobeat') -const { howlong } = require('../src/howlong-tobeat.js') +const { howlong } = require('../../src/howlongtobeat/howlong.js') const fs = require('fs'); const fsp = require('fs').promises; -const { rmdir } = require('./utils') +const { rmdir } = require('./../utils') const mdsample = `--- title: "wizardry 8 review" diff --git a/test/lunr-index-builder.test.js b/test/lunr/index-builder.test.js similarity index 92% rename from test/lunr-index-builder.test.js rename to test/lunr/index-builder.test.js index 738f01b..c97b2c7 100644 --- a/test/lunr-index-builder.test.js +++ b/test/lunr/index-builder.test.js @@ -1,4 +1,4 @@ -const { buildIndex } = require('../src/lunr-index-builder') +const { buildIndex } = require('../../src/lunr/index-builder') let result = null diff --git a/test/postsstub1/2021/03/some-article.md b/test/lunr/postsstub1/2021/03/some-article.md similarity index 100% rename from test/postsstub1/2021/03/some-article.md rename to test/lunr/postsstub1/2021/03/some-article.md diff --git a/test/postsstub2/2021/03/some-article.md b/test/lunr/postsstub2/2021/03/some-article.md similarity index 100% rename from test/postsstub2/2021/03/some-article.md rename to test/lunr/postsstub2/2021/03/some-article.md diff --git a/test/__snapshots__/masto-feed-parser.test.js.snap b/test/mastodon/__snapshots__/feed-parser.test.js.snap similarity index 100% rename from test/__snapshots__/masto-feed-parser.test.js.snap rename to test/mastodon/__snapshots__/feed-parser.test.js.snap diff --git a/test/masto-feed-parser.test.js b/test/mastodon/feed-parser.test.js similarity index 93% rename from test/masto-feed-parser.test.js rename to test/mastodon/feed-parser.test.js index 178d11b..6be9349 100644 --- a/test/masto-feed-parser.test.js +++ b/test/mastodon/feed-parser.test.js @@ -1,12 +1,12 @@ const fs = require('fs'); const fsp = require('fs').promises; -const { rmdir } = require('./utils') +const { rmdir } = require('./../utils') const frontMatterParser = require('parser-front-matter'); jest.mock('got'); -const { parseMastoFeed } = require('../src/masto-feed-parser') +const { parseMastoFeed } = require('../../src/mastodon/feed-parser') const dumpdir = `${__dirname}/dump` describe("mastodon feed parser tests", () => {