GithubHelp home page GithubHelp logo

notangelmario / fresh-seo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xstevenyung/fresh-seo

0.0 0.0 0.0 40 KB

Fork of fresh-seo made for Paquet

License: MIT License

TypeScript 100.00%

fresh-seo's Introduction

Fresh SEO ๐Ÿ‹โ€„โ€„โ€„Badge License

Quickly creating sitemaps for your Deno Fresh project.


Getting Started

Run the setup at the root of your project.

deno run            \
    --allow-read    \
    --allow-write   \
    https://deno.land/x/fresh_seo/init.ts

The following file should have been created:

routes/sitemap.xml.ts


A basic sitemap should now be available at:

http://localhost:8000/sitemap.xml



How does it work?

Fresh SEO ๐Ÿ‹ automatically maps out static routes in your project.

For basic routes, you do not have to do anything manually.


Dynamic Routes

You will still have to map dynamic routes yourself!

// ./routes/sitemap.xml.ts
import { SitemapContext } from 'https://deno.land/x/fresh_seo/mod.ts';
import { Handlers } from '$fresh/server.ts';
import manifest from '../fresh.gen.ts';

export const handler : Handlers = {
    
    GET(request,context){
        
        const sitemap = new SitemapContext(
            'http://example.com'
            manifest
        );

        // You can add additional page here
        sitemap.add('/blog/hello-world');
        return sitemap.render();
    }
}

You can also remove unwanted routes

// ./routes/sitemap.xml.ts
import { SitemapContext } from 'https://deno.land/x/fresh_seo/mod.ts';
import { Handlers } from '$fresh/server.ts';
import manifest from '../fresh.gen.ts';

export const handler : Handlers = {
    
    GET(request,context){
        
        const sitemap = new SitemapContext(
            'http://example.com'
            manifest
        );

        // You can remove unwanted routes here
        sitemap.remove('/gfm.css');
        return sitemap.render();
    }
}


Testing

The test suite can be started with

deno task test

fresh-seo's People

Contributors

electronicsarchiver avatar notangelmario avatar paulalndwhr avatar sinyo-matu avatar xstevenyung 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.