Coder Social home page Coder Social logo

qertis / mobirise-optimizator Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 12 KB

🏗 SEO оптимизатор вашего Mobirise сайта

Home Page: https://baskovsky.ru/2019/07/mobirise/

JavaScript 100.00%
mobirise mobirise-pwa mobirise-turbo gotois

mobirise-optimizator's Introduction

mobirise-optimizator

Remove sponsor link for mobirise web sites.

Install

npm -g install https://github.com/qertis/mobirise-optimizator.git

Example

mobirise-optimizator.js index.html 
    --white-list="gotointeractive.com" 
    --minifier=true 
    --input-dir "./mobirise/" 
    --output-dir "www/"
    --ld-file="static/json-ld.json" 
    --open-search-title="gotois: Search" 
    --open-search-path="//gotointeractive.com/opensearch.xml" 
    --pwa-manifest-path="/manifest.json" 
    --pwa-sw-path="/sw.js" 
    --pwa-install-service-worker-path="/install-service-worker.html" 

Flags

white-list - setup white list anchors

minifier - minimize html tags

input-dir - directory when you save project

output-dir - directory when you public project

ld-file - linked data json file

open-search-title - open search title

open-search-path - path for open search xml manifest

pwa-manifest-path - path for pwa manifest

pwa-sw-path - path for sw pwa

pwa-install-service-worker-path - path for pwa worker

mobirise-optimizator's People

Contributors

qertis avatar

mobirise-optimizator's Issues

Подключить валидацию XML

package.json

"validate-with-xmllint": "1.2.1"

xml-validator.js

const fs = require('fs');
const { validateXML } = require('validate-with-xmllint');

const [nodePath, executorPath, filename] = process.argv;

const file = fs.readFileSync(filename);
const xml = file.toString();

validateXML(xml).then(response => {
  console.log(filename, 'PASS');
}).catch(error => {
  console.error(error.message);
  process.exit(1);
});

test.sh

#!/bin/sh

echo 'XML validate'
XMLs=(sitemap.xml opensearch.xml)
for item in ${XMLs[*]}
do
  node ./xml-validator.js ./www/"$item"
done

AMP validator

package.json

"amphtml-validator": "1.0.35",
  echo 'AMP validating...'
  if amphtml-validator ./www/"$item" --format json | grep -q '"status":"FAIL"'
    then
      echo "fail" $item
      exit 1
    else
      echo "ok" $item
  fi

Добавить Turbify.js

AMP to YaTurbo

node turbify.js $item # где $item=index.html 

turbify.js

const fs = require('fs');
const TR = require('turbo-rss');
const cheerio = require('cheerio');
const pkg = require('../package.json');

const [nodePath, executorPath, filename] = process.argv;
const intput_dir = 'www';
const output_dir = 'www/turbo';

function turbify({ image_url, menu }) {
  fs.mkdir(output_dir, { recursive: true }, (error) => {
    if (error) throw error;
  });
  const page = fs.readFileSync(intput_dir + '/' + filename).toString();
  const $ = cheerio.load(page, {
    normalizeWhitespace: true,
  },);
  const title = $('title').text();
  const body = $('body').html();
  const feed = new TR({
    title: pkg.name,
    description: pkg.description,
    link: pkg.homepage,
    language: 'ru',
  });
  feed.item({
    title,
    image_url,
    url: pkg.homepage + filename,
    author: pkg.author.name,
    date: new Date(),
    content: body,
    menu,
    related: [],
  });
  return feed.xml();
}

const turboPage = turbify({
  image_url: pkg.homepage + 'assets/images/logo-4-512x256.png',
  menu: [{
    link: pkg.homepage,
    text: 'Главная',
  }, {
    link: pkg.homepage + 'manifest',
    text: 'Манифест',
  }, {
    link: pkg.homepage + 'archive',
    text: 'Архив',
  }, {
    link: pkg.homepage + 'mantra',
    text: 'Мантра',
  }, {
    link: pkg.homepage + 'vacancies',
    text: 'Вакансии',
  }]
});
fs.writeFileSync(`${output_dir}/${filename}.xml`, Buffer.from(turboPage));

Сделать алиас для cli

Сейчас требуется явно указывать путь

./node_modules/.bin/mobirise-optimizator index.html --minifier=true --input-dir "./" --output-dir "./public/"

хочется чтобы было просто

mobirise-optimizator --minifier=true --input-dir "./" --output-dir "./public/"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.