Giter Site home page Giter Site logo

angelillo15 / metacsr-generator Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 14 KB

This is a tool to generate an index.html file for each route to have a better SEO with placeholders.

TypeScript 72.04% HTML 7.67% JavaScript 20.29%
client-side-rendering csr html-meta-tags node npm seo seo-optimization seo-tools vite vitejs

metacsr-generator's Introduction

MetaCSR Generator

This is a tool to generate an index.html file for each route to have a better SEO.

Installation

NPM

npm install -D metacsr-generator

Yarn

yarn add -D metacsr-generator

Usage (example for vite)

Create a metacsr.json file in the root of your project with the example configuration below.

{
    "project": "Minearte Web",
    "baseHtmlPath": "./dist/index.html",
    "distPath": "./dist/",
    "routes": [{
        "name": "Home",
        "path": "/",
        "description": "Home page",
        "replaceMap": [{
            "search": "{%title%}",
            "replace": "Home Page"
        }]
    },
    {
        "name": "About",
        "path": "/about",
        "description": "About page",
        "replaceMap": [{
            "search": "{%title%}",
            "replace": "About Page"
        }]
    }]
}

And in your html you can add the placeholders

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" href="/src/assets/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta
      name="description"
      content="{%description%}"
    />

    <title>{%title%}</title>
  </head>
  <body>
    <div id="app"></div>
    <script type="module" src="/src/main.ts"></script>
  </body>
</html>

That will generate this structure

dist/
├── about
│   └── index.html
└── index.html

Here is an example in vite of a package.json

{
  "scripts": {
    "dev": "vite",
    "build": "vue-tsc && vite build && cp dist/index.html dist/404.html && metacsr -v --config metacsr.json",
    "preview": "vite preview"
  },
  "meta-csr-generator": {
    "routes": [
      "/",
      "/about",
      "/contact"
    ]
  }
}

metacsr-generator's People

Contributors

angelillo15 avatar

Stargazers

 avatar

Watchers

 avatar

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.