Skip to content

Commit

Permalink
docs: generate sitemap.xml and robots.txt (#8028)
Browse files Browse the repository at this point in the history
* docs: generate sitemap.xml and robots.txt

* docs: verify ownership for google search console

* Update Robots.txt
  • Loading branch information
dobrinyonkov authored and PetyaMarkovaBogdanova committed Jan 17, 2024
1 parent 749e14e commit 758967c
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ packages/playground/.storybook/custom-elements.json
packages/playground/docs/storybook/**/*
packages/playground/docs/storybook-pages/**/*
!packages/playground/docs/storybook-pages/.gitkeep
packages/playground/public/sitemap.xml

packages/main/test/pages/fix.js
packages/fiori/test/pages/fix.js
Expand Down
3 changes: 2 additions & 1 deletion packages/playground/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const config = {
builder: "@storybook/builder-vite"
},
features: {
storyStoreV7: true
storyStoreV7: true,
buildStoriesJson: true,
},
typescript: {
reactDocgen: 'react-docgen'
Expand Down
20 changes: 20 additions & 0 deletions packages/playground/build-scripts-storybook/sitemap-prepare.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as fs from 'fs';
import * as xmlbuilder from 'xmlbuilder';

console.log('Generating sitemap.xml for playground...');
const data = require('../dist/playground/stories.json');

let xml = xmlbuilder.create('urlset', { version: '1.0', encoding: 'UTF-8' });
xml.att('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');

for (let key in data.stories) {
const kind = data.stories[key]?.kind?.split('/')[0]?.toLowerCase();
xml.ele('url')
.ele('loc', {}, `https://sap.github.io/ui5-webcomponents/playground/?path=/${kind}/${key}`)
.up()
.ele('changefreq', {}, 'monthly');
}

let xmlString = xml.end({ pretty: true });
fs.writeFileSync('./dist/playground/sitemap.xml', xmlString);
console.log('sitemap.xml generated successfully!');
1 change: 1 addition & 0 deletions packages/playground/docs/landing-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<title>UI5 Web Components</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./assets/css/landing-page.css">
<meta name="google-site-verification" content="HDR-jetpFv0oB3i-RQthjtTSdPuN7DMINyPk3oA7pYg" />
<meta name="keywords" content="ui5-webcomponents,ui5 webcomponents,ui5 web components,webcomponents,web components,ui5,api,docs,documentation,sample,usage,examples,demo,Fiori 3,react,angular,vue">
<link type="image/x-icon" href="./assets/images/favicon.ico" rel="shortcut icon">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/themes/prism.css">
Expand Down
8 changes: 6 additions & 2 deletions packages/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"vite-node": "^0.29.8"
},
"scripts": {
"build": "npm run build-storybook",
"build": "npm run build-storybook && npm run build-sitemap",
"build:bundle": "vite build",
"clean": "npm-run-all --parallel clean:*",
"clean:assets": "rimraf ./assets/js/ui5-webcomponents/*",
Expand All @@ -55,6 +55,10 @@
"prepare:manifest": "node ./build-scripts-storybook/parse-manifest.js",
"prepare:documentation": "vite-node ./build-scripts-storybook/documentation-prepare.ts",
"storybook": "npm-run-all --parallel prepare:* && storybook dev -p 6006",
"build-storybook": "npm-run-all --parallel prepare:build:* prepare:* && tsc && storybook build -o ./dist/playground"
"build-storybook": "npm-run-all --parallel prepare:build:* prepare:* && tsc && storybook build -o ./dist/playground",
"build-sitemap": "vite-node ./build-scripts-storybook/sitemap-prepare.ts"
},
"dependencies": {
"xmlbuilder": "^15.1.1"
}
}
7 changes: 7 additions & 0 deletions packages/playground/public/Robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
User-agent: Googlebot
Disallow: /nogooglebot/

User-agent: *
Allow: /

Sitemap: https://sap.github.io/ui5-webcomponents/playground/sitemap.xml
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14842,6 +14842,11 @@ xdg-basedir@^4.0.0:
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-4.0.0.tgz#4bc8d9984403696225ef83a1573cbbcb4e79db13"
integrity sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==

xmlbuilder@^15.1.1:
version "15.1.1"
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-15.1.1.tgz#9dcdce49eea66d8d10b42cae94a79c3c8d0c2ec5"
integrity sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg==

xmlcreate@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/xmlcreate/-/xmlcreate-2.0.4.tgz#0c5ab0f99cdd02a81065fa9cd8f8ae87624889be"
Expand Down

0 comments on commit 758967c

Please sign in to comment.