Skip to content

Commit

Permalink
feat: add version number to rendered pages
Browse files Browse the repository at this point in the history
  • Loading branch information
sapachev committed Jan 24, 2023
1 parent b7c27cf commit a9cd966
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import { DEFAULTS, SRC_CODE_PATTERN, TAILWIND_STYLE } from "./lib/constants";
import { Config, SatusCode, SnippetVariables, TemplateVariables } from "./lib/interfaces";

async function compile(config: Config) {
const pkg = await readJson(DEFAULTS.PACKAGE);
let vars: TemplateVariables = {
locale: config.locale,
version: pkg.version,
};

const template = await readFile(`${DEFAULTS.THEMES}/${config.theme}/template.html`).then(String);
Expand Down
5 changes: 3 additions & 2 deletions lib/_constants.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
exports.DefaultPaths = {
ASSETS: "@assets",
CONFIG: "./config.json",
SRC: "./src",
DIST: "./dist",
PACKAGE: "./package.json",
SNIPPETS: "./snippets",
THEMES: "./themes",
SRC: "./src",
TAILWIND_ENTRY: "main.tcss",
THEMES: "./themes",
};
3 changes: 2 additions & 1 deletion lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { DefaultPaths } from "./_constants.js";
export const DEFAULTS: Defaults = {
ASSETS: DefaultPaths.ASSETS,
CONFIG: DefaultPaths.CONFIG,
SRC: DefaultPaths.SRC,
DIST: DefaultPaths.DIST,
PACKAGE: DefaultPaths.PACKAGE,
SNIPPETS: DefaultPaths.SNIPPETS,
SRC: DefaultPaths.SRC,
THEMES: DefaultPaths.THEMES,
TAILWIND_ENTRY: DefaultPaths.TAILWIND_ENTRY,
};
Expand Down
6 changes: 4 additions & 2 deletions lib/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
export interface Defaults {
ASSETS: string;
CONFIG: string;
SRC: string;
DIST: string;
PACKAGE: string;
SNIPPETS: string;
THEMES: string;
SRC: string;
TAILWIND_ENTRY: string;
THEMES: string;
}

export interface Config {
Expand All @@ -18,6 +19,7 @@ export type SatusCode = number;

export interface TemplateVariables {
locale: string;
version: string;
[key: string]: string | number;
}

Expand Down
4 changes: 2 additions & 2 deletions themes/minimalistic/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="author" content="Pavel Sapachev" />
<meta name="version" content="{{ version }}" />

<link href="/%40assets/css/main.css" rel="preload" as="style" />
<link href="/%40assets/css/main.css" rel="stylesheet" type="text/css" />
<link href="/%40assets/css/main.css?v{{ version }}" rel="stylesheet" type="text/css" />

<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
Expand Down

0 comments on commit a9cd966

Please sign in to comment.