]> git.r.bdr.sh - rbdr/blog/blame_incremental - config/config.js
Remove unnecessary static files
[rbdr/blog] / config / config.js
... / ...
CommitLineData
1import { fileURLToPath } from 'url';
2import { join, resolve, dirname } from 'path';
3import Getenv from 'getenv';
4
5const __filename = fileURLToPath(import.meta.url);
6const __dirname = dirname(__filename);
7
8const internals = {
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',
12 resolve(
13 join(
14 Getenv(
15 'XDG_CONFIG_HOME',
16 join(Getenv('HOME'), '.config')
17 ),
18 'blog'
19 )
20 )
21 ),
22 // We'll use this to store the actual blog contents.
23 dataDirectory: Getenv('BLOG_DATA_DIRECTORY',
24 resolve(
25 join(
26 Getenv(
27 'XDG_DATA_HOME',
28 join(Getenv('HOME'), '.local/share')
29 ),
30 'blog'
31 )
32 )
33 ),
34 // We'll use this to store the actual blog contents.
35 outputDirectory: Getenv('BLOG_OUTPUT_DIRECTORY',
36 resolve(
37 join(
38 Getenv(
39 'XDG_CACHE_HOME',
40 join(Getenv('HOME'), '.cache')
41 ),
42 'blog'
43 )
44 )
45 )
46};
47
48/**
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
51 * the blog object.
52 *
53 * @memberof Blog
54 * @typedef {object} tConfiguration
55 * @property {number} maxPosts=3 the max number of posts that can exist
56 * at one time
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
60 * the blog data.
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,
73 * and index.txt.
74 * @property {string} remoteConfig=$XDG_CONFIG_HOME/blog/blogremotee the
75 * location of the templates we'll use to generate the index.html
76 */
77export default {
78 // XDG_CONFIG_HOME and XDG_DATA_HOME defaults.
79 configDirectory: internals.configDirectory,
80 dataDirectory: internals.dataDirectory,
81 outputDirectory: internals.outputDirectory,
82
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')),
89
90 remoteConfig: resolve(join(internals.configDirectory, 'blogremote')),
91
92 blogOutputDirectory: resolve(join(internals.outputDirectory, 'blog')),
93 archiveOutputDirectory: resolve(join(internals.outputDirectory, 'archive')),
94
95 // Internal config: This can't be modified.
96 defaultTemplatesDirectory: resolve(join(__dirname, '../templates'))
97};