npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

seofix

v1.0.1

Published

An intermediate router is designed to address poor SEO performance in single page applications.

Downloads

26

Readme

SeoFix

SeoFix是一个路由,可以对单页面应用的SEO进行优化,无需使用SSR等服务器渲染技术。

安装

npm install seofix

使用

import Seofix from "seofix";
import * as path from "path";

const sf = new Seofix({
    source_type: 'file',
    source_dir: '${YOUR_SOURCE_DIR}',
    source_app_mode: 'history',
    app_port: 8000,
    app_routes: [
        {
            path: '/articles/:id',
            module: 'articles'
        }
    ]
});

sf.register('articles', (setHtml, setJs, next)=>{
    setHtml(`<h1>Welcome to my website</h1>`);
    setJs("title", "Welcome to my website");
    next();
})

sf.app();

sf.listen(function(){
    console.log("Server started on port 8000");
});

原理

  1. 首先,SeoFix在收到请求时,会先按照所给的配置去请求服务器;
  2. SeoFix根据请求的路径,判断是否匹配到了需要的模块;
  3. SeoFix运行模块,将模块给出的setHtml、setJs拼接之后覆盖在html文件的seofix:content注释中;

框架内使用

框架内使用(React):

import React from "react";

export default function App() {
    return <h1>{window['title']}</h1>
}

框架内使用(Vue):

<template>
    <h1>{{ window['title'] }}</h1>
</template>

进步性 & 局限性

详见:https://blog.csdn.net/Kysou/article/details/142715628

提示

代码极其简单,且封装非常浅层(是本人第一次做npm包),请见谅。