{"id":22729514,"url":"https://github.com/nasa8x/hapi-seo","last_synced_at":"2025-09-06T05:35:34.240Z","repository":{"id":51672723,"uuid":"88105899","full_name":"nasa8x/hapi-seo","owner":"nasa8x","description":"Hapi SEO plugin for Single Page Application (SPA)","archived":false,"fork":false,"pushed_at":"2021-05-10T19:02:43.000Z","size":46,"stargazers_count":1,"open_issues_count":6,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-08T02:07:57.177Z","etag":null,"topics":["hapi","hapi-plugin","hapijs","seo","seo-optimization"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nasa8x.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-12T23:39:02.000Z","updated_at":"2019-11-12T09:03:25.000Z","dependencies_parsed_at":"2022-09-03T18:50:14.891Z","dependency_job_id":null,"html_url":"https://github.com/nasa8x/hapi-seo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nasa8x%2Fhapi-seo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nasa8x%2Fhapi-seo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nasa8x%2Fhapi-seo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nasa8x%2Fhapi-seo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nasa8x","download_url":"https://codeload.github.com/nasa8x/hapi-seo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246262489,"owners_count":20749171,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hapi","hapi-plugin","hapijs","seo","seo-optimization"],"created_at":"2024-12-10T18:10:24.562Z","updated_at":"2025-03-30T00:44:37.680Z","avatar_url":"https://github.com/nasa8x.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hapi SEO plugin for Single Page Application (SPA)\n\nBy defining the same route as the SPA application (Angular, React, Vue, Ember, Aurelia, Backbone ...) The plugin will detect the crawler when the request arrives and return html data.\n\n### If you don't know Node.js \n\n[Node.js Tutorial for Beginners in 2020](https://morioh.com/p/0907cef2141c)\n\n[How To Build a Blog with Nest.js, MongoDB, and Vue.js](https://morioh.com/p/74ffc8a798bb)\n\n[Node.js, ExpressJs, MongoDB and Vue.js (MEVN Stack) Application Tutorial](https://morioh.com/p/5f231039687e)\n\n### Install\n\n```js\nnpm install hapi-seo --save\n```\n```js \nyarn install hapi-seo --save\n```\n\n```js\nvar Hapi = require('@hapi/hapi'),    \n    vision = require('@hapi/vision'),\n    Mustache = require('mustache'),\n    seo = require('hapi-seo'),\n\nvar server = Hapi.server({ host: 'localhost', port: 8080 });\n\nserver.register([\n    {\n        register: vision,\n        options:{}\n    }, \n    {\n        register: seo,\n        options:{\n            enabled: true, // default handler all routes \n            view: 'index.html', // return default view when detect not a crawler      \n            data: {}, // default data view \n            excludes: [ // excludes path or file ext\n                /upload\\/.*?/ig,\n                /www\\/.*?/ig,\n                /\\.(js|css|gif|jpg|jpeg|tiff|png|svg|woff|woff2|ttf|xml|less|doc|txt|docx|ico|zip|rar|mp3|exe|avi|mp4|mpg|mpeg|psd|ai|xsl|m4a|wmv|rss|ppt|flv|swf|dat|dmg|iso|m4v|torrent)$/ig\n            ]\n        }\n    }], function (err) {\n\n       // Register Mustache Templates rendering \n        server.views({\n            engines: {\n                html: {\n                    compile: function (template) {\n                        Mustache.parse(template);\n                        return function (context) {\n                            return Mustache.render(template, context);\n                        };\n                    }\n                }\n            },\n            //relativeTo: __dirname,\n            path: './views'\n        });\n});\n\n```\n\nConfig route return content when detect crawler \n\n```js\nserver.route([\n    {\n        method: 'GET',\n        path: '/category/{id}',\n       handler: function (request, reply) {\n            var _id = request.params.id;\n            var _page = parseInt(request.query.page) || 1;\n            Post.paginate({ _cid: _id }, {                        \n                page: _page,\n                limit: 18,\n                sort: {crt: -1}\n            }, (err, result) =\u003e {\n                if (result) {\n                    reply.view('list.html', result);\n                }else{                    \n                    reply.view('404.html');\n                }\n            });\n            \n        }\n    },\n    {\n        method: 'GET',\n        path: '/detail/{id}',\n        handler: function (request, reply) {\n                Post.findOne({ sid: _id }, (err, doc) =\u003e {\n                if (doc) {\n                    reply.view('detail.html', doc);\n                }else{                    \n                    reply.view('404.html');\n                }\n            });\n                \n        }\n    },\n    // main SPA application\n    {\n        method: 'GET',\n        path: '/{path*}',\n        options: {\n            plugins: {\n                seo: { enabled: false }\n            }          \n\n        },\n\n        handler: function (request, reply) {\n            reply.view('index.html', {});\n        }\n\n    }\n    ]);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnasa8x%2Fhapi-seo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnasa8x%2Fhapi-seo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnasa8x%2Fhapi-seo/lists"}