This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch HDDS-9225-website-v2
in repository https://gitbox.apache.org/repos/asf/ozone-site.git
The following commit(s) were added to refs/heads/HDDS-9225-website-v2 by this
push:
new bd4d74a9 HDDS-10903. Move sitemap check to Docusaurus build. (#94)
bd4d74a9 is described below
commit bd4d74a991862fb0ae02941fd36894aed55012e6
Author: Ethan Rose <[email protected]>
AuthorDate: Mon May 27 22:42:02 2024 -0700
HDDS-10903. Move sitemap check to Docusaurus build. (#94)
---
.github/scripts/url.sh | 47 ----------------------------------------
.github/workflows/docusaurus.yml | 16 --------------
docusaurus.config.js | 30 ++++++++++++++++++++++---
3 files changed, 27 insertions(+), 66 deletions(-)
diff --git a/.github/scripts/url.sh b/.github/scripts/url.sh
deleted file mode 100755
index ac8df495..00000000
--- a/.github/scripts/url.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env sh
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Checks that all URLs contained in the sitemap.xml file from the build
contain only allowed characters.
-# All URLs on the Ozone site should use kebab-case with lowercase letters.
-
-sitemap="$1"
-
-if [ -z "$sitemap" ]; then
- echo "Requires path to sitemap.xml file as the first argument." 1>&2
- exit 1
-fi
-
-# Update this to 'https://ozone\.apache\.org/' when the website is published.
-base_url_regex='https://ozone-site-v2\.staged\.apache\.org/'
-valid_url_regex="$base_url_regex[a-z0-9][a-z0-9\./-]*[a-z0-9/]"
-
-rc=0
-
-for url in $(yq --output-format=props '.urlset.url[].loc' "$sitemap"); do
- if echo "$url" | grep -vx "$base_url_regex" | grep -Exvq
"$valid_url_regex"; then
- echo "Disallowed URL format: $url" 1>&2
- rc=1
- fi
-done
-
-if [ "$rc" != 0 ]; then
- echo "Found URLs in the build that do not match the allowed URL regex:
$valid_url_regex" 1>&2
- echo "All URLs should use kebab case and lowercase letters." 1>&2
-fi
-
-exit "$rc"
diff --git a/.github/workflows/docusaurus.yml b/.github/workflows/docusaurus.yml
index 1b2bdf89..54257741 100644
--- a/.github/workflows/docusaurus.yml
+++ b/.github/workflows/docusaurus.yml
@@ -82,22 +82,6 @@ jobs:
path: build
if-no-files-found: error
retention-days: 1
- check-sitemap:
- needs:
- - build-website
- runs-on: ubuntu-latest
- steps:
- - name: Get URL check script
- uses: actions/checkout@v4
- - name: Download website build artifact
- uses: actions/download-artifact@v4
- with:
- name: build
- path: build
- - name: Check sitemap.xml
- working-directory: ${{ env.script_dir }}
- run: |
- ./url.sh "$GITHUB_WORKSPACE"/build/sitemap.xml
run-website:
needs:
- build-website
diff --git a/docusaurus.config.js b/docusaurus.config.js
index 6054289d..3b44aca5 100644
--- a/docusaurus.config.js
+++ b/docusaurus.config.js
@@ -56,9 +56,12 @@ const config = {
},
markdown: {
- // Validate markdown frontmatter against a more restrictive schema than
what Docusaurus allows.
- // This ensures all pages are using a minimal set of consistent keys.
- // It can also be used to require all pages to define certain markdown
front matter keys.
+ /*
+ Validate markdown frontmatter against a more restrictive schema than what
Docusaurus allows.
+ This ensures all pages are using a minimal set of consistent keys.
+ It can also be used to require all pages to define certain markdown front
matter keys.
+ See https://docusaurus.io/docs/api/docusaurus-config#markdown for
reference.
+ */
parseFrontMatter: async (params) => {
// Reuse the default parser.
const result = await params.defaultParseFrontMatter(params);
@@ -98,6 +101,27 @@ const config = {
require.resolve('./src/css/footer.css'),
],
},
+ sitemap: {
+ /*
+ Check that all generated URLs from the build use kebab-case and
lowercase.
+ See
https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-sitemap#ex-config for
reference.
+ */
+ createSitemapItems: async (params) => {
+ const {defaultCreateSitemapItems, ...rest} = params;
+ const items = await defaultCreateSitemapItems(rest);
+
+ // TODO Base URL must be updated when the new website's branch is
merged.
+ const validUrlRegex = new
RegExp('^https://ozone-site-v2\.staged\.apache\.org/([a-z0-9][a-z0-9\./-]*[a-z0-9/])?$');
+ items.forEach((item, index) => {
+ if (!validUrlRegex.test(item.url)) {
+ console.error('Generated URL', item.url, 'does not match the
allowed RegEx:', validUrlRegex);
+ console.error('All URLs should use kebab case and lowercase
letters.');
+ process.exit(1);
+ }
+ });
+ return items;
+ },
+ },
}),
],
],
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]