The fastest way ⚑️ to create sitemap in your Deno Fresh project πŸ‹

Overview

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();
    }
}


Testing

The test suite can be started with

deno task test

Comments
  • DayJS ESM Import Causing Dependency Conflicts

    DayJS ESM Import Causing Dependency Conflicts

    After running the setup I get errors with the DayJS Import. If I add this to the import map, the issues continue with "fresh/server.ts".

    Console: Task start deno run -A --watch=static/,routes/ dev.ts Watcher Process started. The manifest has been generated for 16 routes and 0 islands. error: Uncaught (in promise) TypeError: Relative import path "dayjs" not prefixed with / or ./ or ../ and not in import map from "https://deno.land/x/[email protected]/src/sitemap.ts" at https://deno.land/x/[email protected]/src/sitemap.ts:7:17 await import(entrypoint); ^ at async dev (https://deno.land/x/[email protected]/src/dev/mod.ts:187:3) at async file:///Users/collectedview/Documents/GitHub/collectedview2023/collectedview/dev.ts:5:1 Watcher Process finished. Restarting on file change...

    opened by collectedview 6
  • Introducing `<Meta />` Component to help users manage meta Infos

    Introducing `` Component to help users manage meta Infos

    Background

    #10

    What changed

    1. Introducing Component
    2. Adding generation of fresh-seo.config.ts which includes meta config.

    Usage

    1. run init.ts script

    This generates fresh-seo.config.ts from user's routes/

    //fresh-seo.config.ts
    import { Config } from "fresh-seo";
    export default {
      routes: {
        "/": {
          title: "index",
          description: "index page",
        },
        "/about": {
          title: "about",
          description: "about page",
        },
      },
    } as Config;
    
    

    2. Add <Meta /> and related imports to page route components

    //index.ts
    import { Handlers, PageProps } from "$fresh/server.ts";
    import { Head } from "$fresh/runtime.ts";
    import seoConfig from "../fresh-seo.config.ts";
    import { MetaProps, getMetaProps } from "fresh-seo";
    import Meta from "fresh-seo/components";
    
    interface Props {
      metaProps: MetaProps;
    }
    
    export const handler: Handlers = {
      GET(req, ctx) {
        const metaProps = getMetaProps(seoConfig, req);
        return ctx.render({ metaProps });
      },
    };
    
     export default function Home({ data }: PageProps<Props>) {
      return (
        <>
          <Head>
            <Meta metaProps={data.metaProps} />
          </Head>
          <div>
         {/* body */}
          </div>
        </>
      );
    }
    

    sample project with demo

    Maybe this inflicts too much user effort :thinking: What do you think?

    opened by sinyo-matu 4
  • Added remove method

    Added remove method

    Hi, @xstevenyung! Your project is really cool! I need this method in my app and I also noticed this solves #1.

    Btw, I upgraded some dependencies. I tested them don't worry.

    opened by notangelmario 4
  • update:add validation functions to validate user input at init.ts script

    update:add validation functions to validate user input at init.ts script

    Background

    In init.ts, I think user input may need some validation to reduce unexpected or confusing behavior.

    Move init.ts script contents into src/ may make our code cleaner

    What Changed

    1. Adding two validation functions: isValidaUrl and isValidDir
    2. Moving init.ts script contents input src/intiFile.ts
    opened by sinyo-matu 3
  • update:remove Dayjs from dependencies, adding a format function instead

    update:remove Dayjs from dependencies, adding a format function instead

    Background

    https://github.com/xstevenyung/fresh-seo/issues/16

    What changed

    1. Removing Dayjs from dependencies
    2. Adding a formatting Date Object YYYY-MM-DD function
    opened by sinyo-matu 1
  • Add editable lastmod&changefreq&priority to SitemapContext

    Add editable lastmod&changefreq&priority to SitemapContext

    Background

    Lastmod, changefreq, and priority attribute values are fixed like below currently.

    • lastmod: The day site to be accessed
    • changefreq: "daily"
    • priority: "0.8"

    If they are editable, users may be happier.

    What changed

    • Adding RouteProps param to SitemapContext@add method then user can select their preferred attribute values.
    • Adding set method to SitemapContext then user can edit existing routes' attribute values.
    • Adding relevant tests

    Note

    I did use deno fmt but some formats have been changed. I was only in purpose of changing sitemap.ts, types.ts and sitemap.test.ts

    opened by sinyo-matu 1
  • Added trailing slash option

    Added trailing slash option

    The current implementation adds options to sitemap generation. Leading slashes are disabled by default, this means that even without specifying it, fresh-seo removes leading slashes.

    Todo: Add documentation

    opened by notangelmario 1
  • Adding generating robots.txt function to init.ts.

    Adding generating robots.txt function to init.ts.

    background

    Related Issue https://github.com/xstevenyung/fresh-seo/issues/3 If I got anything wrong, please correct me.

    what changed

    • Init.ts will receipt a user definition URL for sitemap.xlm.ts and robots.txt generation
    opened by sinyo-matu 0
  • Allow for leading slash or not

    Allow for leading slash or not

    At the moment, we rely on each and every routes added or removed to include a leading slash which can be confusing in some cases.

    We should just allow for either cases.

    β€”

    Created via Raycast

    enhancement help wanted good first issue 
    opened by xstevenyung 0
  • Formatted README

    Formatted README





    Badge Suggestions




    Badge Changes

    • General formatting / spacing

    • Added license badge

    • Linked resources

    • Diff ➞ JS

      Indicated addition through separated sections.

      Syntax coloring is more fresh :lemon:



    Badge Ask

    • If you have any questions.

    • In case you do not agree with some of the changes made in this PR, please first let me know about them, before disregarding it entirely so we can possibly find a middle ground and have it not go to waste.



    Badge Robot

     
                No, I'm not a robot.            
     

     
        Yes, you are not the first.    
     

     
         I just made a PR template.     
     



    Badge Info

    If you want to know more about Markdown check out:


                                [Button MarkedDown]MarkedDown



    opened by ElectronicsArchiver 0
  • Add confirmation message on `init.ts` script to avoid overriding `sitemap.xml.ts` / `robots.txt` if file already exists

    Add confirmation message on `init.ts` script to avoid overriding `sitemap.xml.ts` / `robots.txt` if file already exists

    When running the init.ts script, we assume robots.txt and pages/sitemap.xml.ts are not present in the project and override them.

    We should ask confirmation to override to the user if there already exists.

    enhancement help wanted good first issue 
    opened by xstevenyung 0
  • Sitemap index

    Sitemap index

    It's possible to split sitemaps into different file (https://developers.google.com/search/docs/advanced/sitemaps/large-sitemaps) we should have a way to support that using a new class SitemapIndex

    enhancement 
    opened by xstevenyung 0
Owner
Steven Yung
Freelance fullstack developer πŸ₯ž | Serial unlaunched side-projects maker πŸš€ | Bouldering fanatic πŸ§—
Steven Yung
Dead simple cookie-based session for Deno Fresh.

Fresh Session ?? Dead simple cookie-based session for Deno Fresh. Get started Fresh Session comes with a simple middleware to add at the root of your

Steven Yung 38 Jan 5, 2023
Simple store for Deno Fresh, to pass state between islands

Fresh Store A minimal store for Fresh, to allow communication between islands. It attach stores to the window component. It uses "pointers" or "keys"

Alexandre Moreau-Lemay 9 Sep 12, 2022
A minimal blog template using the Fresh framework for Deno.

Fresh Blog This is a minimal blog template using the awesome framework Fresh from Deno. Usage Start the project: deno task start This will watch the

Little Sticks 21 Dec 16, 2022
Opinionated collection of TypeScript definitions and utilities for Deno and Deno Deploy. With complete types for Deno/NPM/TS config files, constructed from official JSON schemas.

Schemas Note: You can also import any type from the default module, ./mod.ts deno.json import { type DenoJson } from "https://deno.land/x/[email protected]

deno911 2 Oct 12, 2022
Collection of SEO utilities like sitemap, robots.txt, etc. for a Remix Application

Remix SEO Collection of SEO utilities like sitemap, robots.txt, etc. for a Remix Features Generate Sitemap Generate Robots.txt Installation To use it,

Balavishnu V J 128 Dec 21, 2022
Simple CLI to warm the cache of social images in all pages from a sitemap.

warm-social-images Simple CLI to warm the cache of social images in all pages from a sitemap. Why Using serverless functions to generate images for so

Travis Fischer 9 Jul 7, 2022
Postgres.js - The Fastest full featured PostgreSQL client for Node.js and Deno

?? Fastest full-featured node & deno client ?? ES6 Tagged Template Strings at the core ??‍♀️ Simple surface API ??️ Dynamic query support ?? Chat and

Rasmus Porsager 4.3k Jan 1, 2023
Fastest JavaScript client for MySQL, with Deno FFI.

mysql-native The fastest [1] JavaScript MySQL client. import { Connection } from "https://deno.land/x/mysql_native/mod.ts"; const conn = new Connectio

Deno Drivers 7 Sep 27, 2022
Fastest way to get financial data from Plaid into your Postgres database. Go from zero to live in 5 minutes without a single line of code.

Venice Venice is a the fastest way to get financial data from Plaid into your Postgres database. Zero to production in 5 minutes without a single line

Venice 93 Dec 12, 2022
CryptoDappy is the fastest way to get started with Flow.

Demo application (testnet) Learning hub (start learning here) What's CryptoDappy? CryptoDappy is the fastest way to get started with blockchain develo

Benjamin Ebner 91 Aug 18, 2022
The Omnibookmarks browser extension is the fastest way to open bookmarks

β˜… Omnibookmarks The Omnibookmarks browser extension is the fastest way to open bookmarks. Just type a keyword into the address bar to quickly open or

Nate Hill 16 Aug 20, 2022
The fastest way to get started with a fully-fledged web3 frontend

create-web3-frontend The fastest way to get started with a fully-fledged web3 frontend setup consisting of Next.js, wagmi and Tailwind CSS. npx create

Dhaiwat Pandya 153 Dec 28, 2022
An efficient (and the fastest!) way to search the web privately using Brave Search Engine

Brave Search An efficient (and the fastest) way to search the web privately using Brave Search Engine. Not affiliated with Brave Search. Tested on Chr

Jishan Shaikh 7 Jun 2, 2022
Easy server-side and client-side validation for FormData, URLSearchParams and JSON data in your Fresh app πŸ‹

Fresh Validation ??     Easily validate FormData, URLSearchParams and JSON data in your Fresh app server-side or client-side! Validation Fresh Validat

Steven Yung 20 Dec 23, 2022
A fresh look for the Hackage. Follow us: https://twitter.com/HackageUI

Hackage UI Fresh look for the https://hackage.haskell.org/. Work in progress. Search Search on Hoogle. Search on Hackage. Full-text search integration

visortelle 97 Dec 28, 2022
A demonstration app for Fresh that shows how to use SSR, the islands functionality, APIs and more

Fresh Pokemon Demo Code This is a demonstration app for Fresh that shows how to use SSR, the islands functionality, APIs and more. You do need to conn

Jack Herrington 23 Dec 18, 2022
Fresh SQLite example on Fly.io.

fresh-sqlite-example Fresh example with SQLite and kysely query builder. See running example on Fly.io. Prerequisites Deno v1.23 or higher SQLite Opti

Michal Vavra 6 Nov 25, 2022
View component and controller of YouTube Player API, for fresh framework.

fresh-youtube View component and controller of YouTube Player API, for fresh framework. Try it now! git clone [email protected]:otiai10/fresh-youtube.git

Hiromu OCHIAI 10 Nov 2, 2022
This is a simple boilerplate for a Deno website, deployed with Deno Deploy.

Simple Deno Website Boilerplate This is a simple website boilerplate built using Deno and deployed using Deno Deploy. Demo at simple-deno-website-boil

Bruno Bernardino 15 Dec 3, 2022