]>
Commit | Line | Data |
---|---|---|
6cd62e79 RBR |
1 | import { fileURLToPath } from 'url'; |
2 | import { join, resolve, dirname } from 'path'; | |
3 | import Getenv from 'getenv'; | |
cf630290 | 4 | |
6cd62e79 RBR |
5 | const __filename = fileURLToPath(import.meta.url); |
6 | const __dirname = dirname(__filename); | |
cf630290 | 7 | |
c5cbbd38 | 8 | const internals = { |
6cd62e79 RBR |
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 | ) | |
c5cbbd38 | 46 | }; |
cf630290 BB |
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 | |
6cd62e79 RBR |
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 | |
cf630290 | 64 | * the directory where the posts will be stored. |
6cd62e79 RBR |
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 | |
cf630290 BB |
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. | |
6cd62e79 RBR |
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 | |
cf630290 BB |
75 | * location of the templates we'll use to generate the index.html |
76 | */ | |
6cd62e79 RBR |
77 | export 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. | |
cf630290 | 84 | maxPosts: Getenv.int('BLOG_MAX_POSTS', 3), |
6cd62e79 RBR |
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. | |
10a76a5b | 96 | defaultTemplatesDirectory: resolve(join(__dirname, '../templates')) |
cf630290 | 97 | }; |