Skip to content

Commit

Permalink
use camelcase for config keys
Browse files Browse the repository at this point in the history
  • Loading branch information
kkga committed Nov 15, 2022
1 parent ff70fd9 commit 833408e
Show file tree
Hide file tree
Showing 7 changed files with 280 additions and 76 deletions.
9 changes: 5 additions & 4 deletions .ter/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"title": "Ter",
"description": "A tiny wiki-style site builder with Zettelkasten flavor",
"url": "https://ter.kkga.me/",
"author_name": "Gadzhi Kharkharov",
"author_email": "[email protected]",
"author_url": "https://kkga.me/",
"nav_links": {
"authorName": "Gadzhi Kharkharov",
"authorEmail": "[email protected]",
"authorUrl": "https://kkga.me/",
"navLinks": {
"Usage": "/usage",
"Source": "https://github.com/kkga/ter"
},
"codeHighlight": true,
"head": "<script data-host='https://microanalytics.io' data-dnt='false' src='https://microanalytics.io/js/script.js' id='ZwSg9rf6GA' async defer></script>"
}
11 changes: 6 additions & 5 deletions config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ const defaultUserConfig: UserConfig = {
description: "I am writing about my experiences as a naval navel-gazer",
url: "https://example.com/",
rootCrumb: "index",
author_name: "Your Name Here",
author_email: "[email protected]",
author_url: "https://example.com/about-me/",
authorName: "Your Name Here",
authorEmail: "[email protected]",
authorUrl: "https://example.com/about-me/",
codeHighlight: false,
lang: "en",
};

Expand Down Expand Up @@ -76,11 +77,11 @@ export async function createConfig(
conf.renderDrafts = opts.renderDrafts;

await checkUserConfig(conf.userConfigPath)
.catch(async () => {
.catch(() => {
console.warn(
`Config file missing, initializing default config at ${conf.userConfigPath}`,
);
await initUserConfig(conf.userConfig, conf.userConfigPath);
initUserConfig(conf.userConfig, conf.userConfigPath);
});

try {
Expand Down
205 changes: 205 additions & 0 deletions deno.lock

Large diffs are not rendered by default.

16 changes: 6 additions & 10 deletions docs/gfm.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ This is a code block following a header.
| A table | A header |
| A table | A header |

---

There's a horizontal rule above and below this.

---

Here is an unordered list:

- Salt-n-Pepa
Expand Down Expand Up @@ -106,6 +100,12 @@ And a nested list:
- Donatello
- Raphael

---

There's a horizontal rule above and below this.

---

Definition lists can be used with HTML syntax.

<dl>
Expand Down Expand Up @@ -149,8 +149,6 @@ If a table is too wide, it should condense down and/or scroll horizontally.
| Prince | Purple Rain | 1984 | Warner Brothers Records | Grammy Award for Best Score Soundtrack for Visual Media, American Music Award for Favorite Pop/Rock Album, American Music Award for Favorite Soul/R&B Album, Brit Award for Best Soundtrack/Cast Recording, Grammy Award for Best Rock Performance by a Duo or Group with Vocal | Let's Go Crazy, Take Me With U, The Beautiful Ones, Computer Blue, Darling Nikki, When Doves Cry, I Would Die 4 U, Baby I'm a Star, Purple Rain |
| Beastie Boys | License to Ill | 1986 | Mercury Records | noawardsbutthistablecelliswide | Rhymin & Stealin, The New Style, She's Crafty, Posse in Effect, Slow Ride, Girls, (You Gotta) Fight for Your Right, No Sleep Till Brooklyn, Paul Revere, Hold It Now, Hit It, Brass Monkey, Slow and Low, Time to Get Ill |

---

Code snippets like `var foo = "bar";` can be shown inline.

Also, `this should vertically align` ~~`with this`~~ ~~and this~~.
Expand Down Expand Up @@ -202,8 +200,6 @@ Inline code inside table cells should still be distinguishable.
| Javascript | `var foo = "bar";` |
| Ruby | `foo = "bar"` |

---

Small images should be shown at their actual size.

![Bridge](img/img-small.jpg)
Expand Down
94 changes: 47 additions & 47 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,32 @@ Navigate to a directory with some markdown files and run Ter to build a site.
This command will recursively search for all `*.md` files in the current
directory and generate a site into the `_site` directory:

```sh
```
deno run -A --unstable https://deno.land/x/ter/main.ts
```

If your markdown files are not in root directory, or if you want a different
name for the output directory, adjust accordingy, for example:

```sh
```
deno run -A --unstable https://deno.land/x/ter/main.ts --input pages --output _dist
```

To start a local server with live refresh, pass the `--serve` flag:

```sh
```
deno run -A --unstable https://deno.land/x/ter/main.ts --serve
```

## Command line usage

Run Ter with the `--help` flag to see usage reference.

```sh
```
deno run https://deno.land/x/ter/main.ts --help
```

```sh
```
Ter -- tiny wiki-style site builder
USAGE:
Expand All @@ -73,35 +73,37 @@ building.

### Options

| Key | Description |
| -------------- | --------------------------------------------------------------------- |
| `title` | Title of your site. |
| `description` | Description of your site. |
| `url` | Published URL address of your site. |
| `rootCrumb` | Label used for root crumb label (default: "index"). |
| `author_name` | Your name. |
| `author_email` | Your email. |
| `author_url` | Your home page. |
| `lang` | Optional. [Locale][locale] used for formatting dates. |
| `nav_links` | Optional. Object of navigation links in form of `{label: path, ...}`. |
| `head` | Optional. String to inject at the bottom of `<head>` tag. |
| Key | Description |
| ------------- | --------------------------------------------------------------------- |
| title | Title of your site. |
| description | Description of your site. |
| url | Published URL address of your site. |
| rootCrumb | Label used for root crumb label (default: "index"). |
| authorName | Your name. |
| authorEmail | Your email. |
| authorUrl | Your home page. |
| lang | Optional. [Locale][locale] used for formatting dates. |
| navLinks | Optional. Object of navigation links in form of `{label: path, ...}`. |
| codeHighlight | Optional. Use syntax highlighting in code blocks (default: false). |
| head | Optional. String to inject at the bottom of `<head>` tag. |

[locale]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument

### Example

```json
{
title: "Your Blog Name",
description: "I am writing about my experiences as a naval navel-gazer",
url: "https://example.com/",
rootCrumb: "index",
author_name: "Your Name Here",
author_email: "[email protected]",
author_url: "https://example.com/about-me/",
lang: "en",
nav_links: { "about": "/about", "contact": "/contact" },
head: "<script src='https://microanalytics.io/js/script.js' id='XXXXXXXX'></script>"
"title": "Your Blog Name",
"description": "I am writing about my experiences as a naval navel-gazer",
"url": "https://example.com/",
"rootCrumb": "index",
"authorName": "Your Name Here",
"authorEmail": "[email protected]",
"authorUrl": "https://example.com/about-me/",
"lang": "en",
"navLinks": { "about": "/about", "contact": "/contact" },
"codeHighlight": true,
"head": "<script src='https://microanalytics.io/js/script.js' id='XXXXXXXX'></script>"
}
```

Expand Down Expand Up @@ -142,7 +144,7 @@ pages.
Ter extracts [YAML frontmatter](https://jekyllrb.com/docs/front-matter/)
delimited by `---` from markdown files. Here’s an example:

```markdown
```yaml
---
title: My page
description: Here’s my description
Expand All @@ -154,28 +156,26 @@ property: value
---

## My content

...
```

Some properties are utilized when building a site. All of them are optional.

| Property | Default | Description |
| ----------------- | ------- | ------------------------------------------------------------------------- |
| `title` | | page title |
| `description` | | page description |
| `tags` | | page tags |
| `date` | | page publish date in YYYY-MM-DD format |
| `dateUpdated` | | page last update date in YYYY-MM-DD format |
| `pinned` | `false` | page is listed at the top of [index lists](#index-pages) |
| `unlisted` | `false` | page is excluded from all index lists |
| `draft` | `false` | file is [ignored](#ignoring-files) during site generation |
| `log` | `false` | if set on an index page (`index.md`), all child pages are rendered inline |
| `toc` | `false` | affects rending of table of contents |
| `showHeader` | `true` | affects rendering of page header with title, description, date and tags |
| `showTitle` | `true` | affects rendering of page title |
| `showDescription` | `true` | affects rendering of page description |
| `showMeta` | `true` | affects rendering of page date and tags |
| Property | Default | Description |
| --------------- | ------- | ----------------------------------------------------------------------- |
| title | | page title |
| description | | page description |
| tags | | page tags |
| date | | page publish date in YYYY-MM-DD format |
| dateUpdated | | page last update date in YYYY-MM-DD format |
| pinned | false | page is listed at the top of [index lists](#index-pages) |
| unlisted | false | page is excluded from all index lists |
| draft | false | file is [ignored](#ignoring-files) during site generation |
| log | false | if set on an index page (index.md), all child pages are rendered inline |
| toc | false | affects rending of table of contents |
| showHeader | true | affects rendering of page header with title, description, date and tags |
| showTitle | true | affects rendering of page title |
| showDescription | true | affects rendering of page description |
| showMeta | true | affects rendering of page date and tags |

## Ignoring files

Expand All @@ -196,7 +196,7 @@ deno run -A --unstable https://deno.land/x/ter/main.ts --serve --drafts
Ter automatically finds non-working internal links and lets you know about them
after building a site. Here's an example output:

```sh
```
[...]
Dead links:
/overview -> /non-existent-page-name
Expand Down
12 changes: 6 additions & 6 deletions feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export function generateFeed(opts: FeedOpts): Feed {
description,
url,
lang,
author_name,
author_email,
author_url,
authorName,
authorEmail,
authorUrl,
} = userConfig;

const feed = new Feed({
Expand All @@ -31,9 +31,9 @@ export function generateFeed(opts: FeedOpts): Feed {
atom: `${url}/feed`,
},
author: {
name: author_name,
email: author_email,
link: author_url,
name: authorName,
email: authorEmail,
link: authorUrl,
},
});

Expand Down
9 changes: 5 additions & 4 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ export interface UserConfig {
description: string;
url: string;
rootCrumb: string;
author_name: string;
author_email: string;
author_url: string;
authorName: string;
authorEmail: string;
authorUrl: string;
codeHighlight: boolean;
navLinks?: Record<string, string>;
lang?: Intl.LocalesArgument;
nav_links?: Record<string, string>;
head?: string;
}

Expand Down

0 comments on commit 833408e

Please sign in to comment.