Skip to content

Commit

Permalink
feat: 🎸 pipe in hostname from elder.config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Reese committed May 19, 2021
1 parent 4e0c76b commit 6b7f696
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/seo-check/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const { Tester, defaultPreferences, rules } = require('@nickreese/seo-lint');
const fs = require('fs');
const path = require('path');
const url = require('url');

const notProd = process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'PRODUCTION';

Expand All @@ -10,10 +11,20 @@ const plugin = {
description: 'Checks Elder.js generated HTML for common SEO issues.',
init: (plugin) => {
// used to store the data in the plugin's closure so it is persisted between loads
let host;
try {
const parsed = new url.URL(plugin.settings.origin);
if (parsed) {
host = parsed.hostname;
}
} catch (e) {
// invalid url.
}

plugin.tester = new Tester({
display: plugin.config.display,
siteWide: plugin.settings.context === 'build',
host,
});

return plugin;
Expand Down

0 comments on commit 6b7f696

Please sign in to comment.