diff --git a/LICENSE.md b/LICENSE.md index 1bb5f69..2c5f514 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Thiago Santos +Copyright (c) 2017 Gustavo Quinalha Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/bin/seotopper.js b/bin/seotopper.js index 633baba..13ca945 100644 --- a/bin/seotopper.js +++ b/bin/seotopper.js @@ -7,7 +7,7 @@ const questions = [ { type: 'input', name: 'title', - message: 'What\'s the title of your page (required)', + message: 'What\'s the title of your page', validate: value => { if (value === '') { return 'Please enter a title' @@ -95,11 +95,104 @@ const questions = [ type: 'input', name: 'themeColor', message: 'What\'s the theme-color of your page' + }, + { + type: 'confirm', + name: 'facebook', + message: 'Do you wanna seo for facebook' + }, + { + type: 'list', + name: 'facebookType', + message: 'What\'s the type of your page', + choices: [ + 'website', + 'blog', + 'article', + 'activity', + 'sport', + 'company', + 'restaurant', + 'hotel', + 'cause', + 'band', + 'government', + 'non_profit', + 'school', + 'university', + 'actor', + 'athlete', + 'city', + 'country', + 'album', + 'book', + 'drink', + 'game', + 'product', + 'song', + 'movie' + ], + when: answers => { + return answers.facebook + } + }, + { + type: 'input', + name: 'facebookSiteName', + message: 'What\'s the name of your page on facebook', + when: answers => { + return answers.facebook + } + }, + { + type: 'input', + name: 'facebookLocale', + message: 'What\'s the locale of your page on facebook', + when: answers => { + return answers.facebook + } + }, + { + type: 'input', + name: 'facebookId', + message: 'What\'s the id of your page on facebook', + when: answers => { + return answers.facebook + } + }, + { + type: 'input', + name: 'facebookAdmins', + message: 'What are the admins of your page on facebook', + when: answers => { + return answers.facebook + } + }, + { + type: 'confirm', + name: 'twitter', + message: 'Do you wanna seo for twitter' + }, + { + type: 'list', + name: 'twitterCard', + message: 'Which twitter do you want', + choices: [ + 'Summary', + 'Product', + 'Photo', + 'Summary Large Image', + 'Player', + 'App', + 'Gallery' + ], + when: answers => { + return answers.twitter + } } ] inquirer.prompt(questions).then(answers => { const generatedSEO = seotopper(answers) - // Process.stdout.write(generatedSEO) - console.log(generatedSEO) + process.stdout.write(generatedSEO) }) diff --git a/lib/seotopper.js b/lib/seotopper.js index 61259b7..01743b5 100644 --- a/lib/seotopper.js +++ b/lib/seotopper.js @@ -43,21 +43,33 @@ function seotopper(args) { ${args.facebook ? ` - + - - + + ${args.facebookSiteName ? + `` : + '' + } - - - ` : + ${args.facebookLocale ? + `` : + '' + } + ${args.facebookId ? + `` : + '' + } + ${args.facebookAdmins ? + `` : + '' + }` : '' } ${args.twitter ? ` - + diff --git a/test/seotopper.test.js b/test/seotopper.test.js index fc26526..285d0b7 100644 --- a/test/seotopper.test.js +++ b/test/seotopper.test.js @@ -12,16 +12,14 @@ test('main funcionality', t => { robots: 'index/follow', themeColor: '#f00', image: 'https://sua-url.com.br/images/intro.jpg', - facebook: { - type: 'website', - siteName: 'Exemplo', - locale: 'pt_BR', - id: '5349', - admins: '123456789' - }, - twitter: { - card: 'summary' - } + facebook: true, + facebookType: 'website', + facebookSiteName: 'Exemplo', + facebookLocale: 'pt_BR', + facebookId: '5349', + facebookAdmins: '123456789', + twitter: true, + twitterCard: 'summary' }) const expected = `Título da minha página @@ -42,7 +40,7 @@ test('main funcionality', t => { - + @@ -79,16 +77,14 @@ test('base should be optional', t => { robots: 'index/follow', themeColor: '#f00', image: 'https://sua-url.com.br/images/intro.jpg', - facebook: { - type: 'website', - siteName: 'Exemplo', - locale: 'pt_BR', - id: '5349', - admins: '123456789' - }, - twitter: { - card: 'summary' - } + facebook: true, + facebookType: 'website', + facebookSiteName: 'Exemplo', + facebookLocale: 'pt_BR', + facebookId: '5349', + facebookAdmins: '123456789', + twitter: true, + twitterCard: 'summary' }) t.notRegex(actual, /rel="base"/) @@ -103,16 +99,14 @@ test('sitemap should be optional', t => { robots: 'index/follow', themeColor: '#f00', image: 'https://sua-url.com.br/images/intro.jpg', - facebook: { - type: 'website', - siteName: 'Exemplo', - locale: 'pt_BR', - id: '5349', - admins: '123456789' - }, - twitter: { - card: 'summary' - } + facebook: true, + facebookType: 'website', + facebookSiteName: 'Exemplo', + facebookLocale: 'pt_BR', + facebookId: '5349', + facebookAdmins: '123456789', + twitter: true, + twitterCard: 'summary' }) t.notRegex(actual, /rel="sitemap"/) @@ -126,16 +120,14 @@ test('themeColor should be optional', t => { canonical: 'https://sua-url.com.br', robots: 'index/follow', image: 'https://sua-url.com.br/images/intro.jpg', - facebook: { - type: 'website', - siteName: 'Exemplo', - locale: 'pt_BR', - id: '5349', - admins: '123456789' - }, - twitter: { - card: 'summary' - } + facebook: true, + facebookType: 'website', + facebookSiteName: 'Exemplo', + facebookLocale: 'pt_BR', + facebookId: '5349', + facebookAdmins: '123456789', + twitter: true, + twitterCard: 'summary' }) t.notRegex(actual, /name="theme-color"/) @@ -151,9 +143,8 @@ test('facebook should be optional', t => { canonical: 'https://sua-url.com.br', robots: 'index/follow', image: 'https://sua-url.com.br/images/intro.jpg', - twitter: { - card: 'summary' - } + twitter: true, + twitterCard: 'summary' }) t.notRegex(actual, /property="og:type"/) t.notRegex(actual, /property="og:title"/) @@ -174,13 +165,12 @@ test('twitter should be optional', t => { canonical: 'https://sua-url.com.br', robots: 'index/follow', image: 'https://sua-url.com.br/images/intro.jpg', - facebook: { - type: 'website', - siteName: 'Exemplo', - locale: 'pt_BR', - id: '5349', - admins: '123456789' - } + facebook: true, + facebookType: 'website', + facebookSiteName: 'Exemplo', + facebookLocale: 'pt_BR', + facebookId: '5349', + facebookAdmins: '123456789' }) t.notRegex(actual, /name="twitter:card"/) t.notRegex(actual, /name="twitter:title"/)