]>
git.r.bdr.sh - rbdr/blog/blob - config/config.js
531f3e9358cf685a98e96f5eac4e61cad0ef4e75
1 import { fileURLToPath
} from 'url';
2 import { join
, resolve
, dirname
} from 'path';
3 import Getenv
from 'getenv';
5 const __filename
= fileURLToPath(import.meta
.url
);
6 const __dirname
= dirname(__filename
);
9 // We'll use this to store configuration, such as the remote config,
10 // templates, and the static directory.
11 configDirectory: Getenv('BLOG_CONFIG_DIRECTORY',
16 join(Getenv('HOME'), '.config')
22 // We'll use this to store the actual blog contents.
23 dataDirectory: Getenv('BLOG_DATA_DIRECTORY',
28 join(Getenv('HOME'), '.local/share')
34 // We'll use this to store the actual blog contents.
35 outputDirectory: Getenv('BLOG_OUTPUT_DIRECTORY',
40 join(Getenv('HOME'), '.cache')
49 * The main configuration object for Blog. It will be used to
50 * initialize all of the sub-components. It can extend any property of
54 * @typedef {object} tConfiguration
55 * @property {number} maxPosts=3 the max number of posts that can exist
57 * @property {string} configDirectory=$XDG_CONFIG_HOME/blog the location of
58 * the configuration files.
59 * @property {string} dataDirectory=$XDG_DATA_HOME/blog the location of
61 * @property {string} outputDirectory=$XDG_CACHE_HOME/blog the location of
62 * the generated blog files.
63 * @property {string} postsDirectory=$XDG_DATA_HOME/blog/posts the location of
64 * the directory where the posts will be stored.
65 * @property {string} archiveDirectory=$XDG_DATA_HOME/blog/archive the location of
66 * the directory where the archive will be stored.
67 * @property {string} staticDirectory=$XDG_DATA_HOME/blog/static the location of
68 * the directory where the generated files will be placed. NOTE: There
69 * are some pre-built style files in the default directory, if you
70 * select another one, make sure you include them manually.
71 * @property {string} templatesDirectory=$XDG_CONFIG_HOME/blog/templates the
72 * location of the templates we'll use to generate the index.html, feed.xml,
74 * @property {string} remoteConfig=$XDG_CONFIG_HOME/blog/blogremotee the
75 * location of the templates we'll use to generate the index.html
78 // XDG_CONFIG_HOME and XDG_DATA_HOME defaults.
79 configDirectory: internals
.configDirectory
,
80 dataDirectory: internals
.dataDirectory
,
81 outputDirectory: internals
.outputDirectory
,
83 // User configuration, changeable with BLOG_ env variables.
84 maxPosts: Getenv
.int('BLOG_MAX_POSTS', 3),
85 postsDirectory: resolve(join(internals
.dataDirectory
, 'posts')),
86 archiveDirectory: resolve(join(internals
.dataDirectory
, 'archive')),
87 staticDirectory: resolve(join(internals
.dataDirectory
, 'static')),
88 templatesDirectory: resolve(join(internals
.dataDirectory
, 'templates')),
90 remoteConfig: resolve(join(internals
.configDirectory
, 'blogremote')),
92 blogOutputDirectory: resolve(join(internals
.outputDirectory
, 'blog')),
93 archiveOutputDirectory: resolve(join(internals
.outputDirectory
, 'archive')),
95 // Internal config: This can't be modified.
96 defaultTemplatesDirectory: resolve(join(__dirname
, '../templates')),