1
0
mirror of https://github.com/GenderDysphoria/GenderDysphoria.fyi.git synced 2025-11-25 20:42:40 +00:00

Refining engine targeting

This commit is contained in:
Jocelyn Badgley (Twipped)
2020-03-07 18:04:37 -08:00
parent 4e5c14123f
commit 67b168dba1
7 changed files with 188 additions and 125 deletions

View File

@@ -1,7 +1,7 @@
const path = require('path');
const { without } = require('lodash');
const { resolve, isCleanUrl } = require('./resolve');
const { resolve, isCleanUrl, TYPE, ENGINE } = require('./resolve');
const Page = require('./page');
const slugs = require('slugify');
const slugify = (s) => slugs(s, { remove: /[*+~.,()'"!?:@/\\]/g }).toLowerCase();
@@ -17,6 +17,17 @@ function arrayify (input) {
module.exports = exports = class Post extends Page {
_engine () {
switch (this.type) {
case TYPE.HANDLEBARS:
return TYPE.HANDLEBARS;
case TYPE.MARKDOWN:
return ENGINE.POST;
default:
return ENGINE.OTHER;
}
}
_dir (dir) {
// if the file name matches the postmatch pattern, then this needs to be /p/ file
const match = this.name.match(postmatch);
@@ -61,6 +72,8 @@ module.exports = exports = class Post extends Page {
_parse (...args) {
super._parse(...args);
if (!this.titlecard) this.titlecard = '/tweets/titlecard.png';
this.meta.tags = (this.meta.tags || []).reduce((result, tag) => {
result[slugify(tag)] = tag;
return result;