mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-01-30 23:06:18 +00:00
Internalize PostAsset into Posts
This commit is contained in:
parent
8796f52c9d
commit
de4dfd765d
@ -1,16 +0,0 @@
|
||||
|
||||
const { without } = require('lodash');
|
||||
const Asset = require('./asset');
|
||||
|
||||
const postmatch = /(\d{4}-\d\d-\d\d)\.\d{4}\.(\w+)/;
|
||||
|
||||
module.exports = exports = class PostAsset extends Asset {
|
||||
|
||||
_dir (dir) {
|
||||
dir = dir.replace(postmatch, '$2').split('/');
|
||||
dir = without(dir, 'posts', '_images');
|
||||
dir.unshift('p');
|
||||
return dir;
|
||||
}
|
||||
|
||||
};
|
@ -1,7 +1,7 @@
|
||||
const glob = require('./lib/glob');
|
||||
const { ROOT, KIND } = require('./resolve');
|
||||
const File = require('./file');
|
||||
const Asset = require('./post-asset');
|
||||
const { without } = require('lodash');
|
||||
const Asset = require('./asset');
|
||||
const Post = require('./post');
|
||||
const Files = require('./files');
|
||||
|
||||
@ -9,8 +9,7 @@ class PostFiles extends Files {
|
||||
_kindMap () {
|
||||
return {
|
||||
[KIND.PAGE]: Post,
|
||||
[KIND.ASSET]: Asset,
|
||||
[KIND.OTHER]: File,
|
||||
[KIND.ASSET]: PostAsset,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -19,3 +18,15 @@ module.exports = exports = async function loadPublicFiles () {
|
||||
return new PostFiles(await glob('posts/**/*', { cwd: ROOT, nodir: true }));
|
||||
};
|
||||
|
||||
const POSTMATCH = /(\d{4}-\d\d-\d\d)\.\d{4}\.(\w+)/;
|
||||
|
||||
class PostAsset extends Asset {
|
||||
|
||||
_dir (dir) {
|
||||
dir = dir.replace(POSTMATCH, '$2').split('/');
|
||||
dir = without(dir, 'posts', '_images');
|
||||
dir.unshift('p');
|
||||
return dir;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user