Skip to content

Commit

Permalink
build: Ability to publish Pages with document type XML (#3316)
Browse files Browse the repository at this point in the history
## Description

ref #3308 

Ability to render Pages with document type equal to `xml` 

If page with document type xml is created and has path `/sitemap.xml`
this page is rendered as sitemap
otherwise implicit sitemap.xml is generated.

On publish we use following logic for rendering.

With doctype === xml
- we are rendering XmlNode as is
- `Body` rendered as `(props) => props.children`, 
- all other elements as `() => null`


- [x] - sitemap.xml must be excluded from sitemap

## Steps for reproduction

### Example Saas Sitemap with $resource and custom section and headers
mixed with XmlNode

- App builder
https://xml-gen.staging.webstudio.is/builder/d6bcc915-6634-4e2d-9ef1-90e8e3836003?pageId=KrgWBi6ANVxH2BfRbar19
- Published https://saas-sitemapxml-x1g2n.wstd.work/sitemap.xml

### Implicit sitemap
- App builder
https://xml-gen.staging.webstudio.is/builder/96168940-4fbd-454a-9a03-ba4f2dffbbec
- Published https://saas-january-th6m1.wstd.work/sitemap.xml


Example with custom section and non XmlNode elements
<img width="784" alt="image"
src="https://github.com/webstudio-is/webstudio/assets/5077042/47520bf8-bb77-4c0f-b44d-011cf2cf9814">



### Example Saas without explicit sitemap



## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory

---------

Co-authored-by: Oleg Isonen <[email protected]>
  • Loading branch information
istarkov and kof authored May 8, 2024
1 parent f529723 commit 0571d2d
Show file tree
Hide file tree
Showing 39 changed files with 519 additions and 997 deletions.
1 change: 1 addition & 0 deletions fixtures/webstudio-cloudflare-template/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
force=true
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { LoaderFunctionArgs } from "@remix-run/server-runtime";
import { sitemap } from "../__generated__/[sitemap.xml]";
import { sitemap } from "../__generated__/$resources.sitemap.xml";

export const loader = (arg: LoaderFunctionArgs) => {
const host =
Expand Down
1 change: 1 addition & 0 deletions fixtures/webstudio-custom-template/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
force=true
Loading

0 comments on commit 0571d2d

Please sign in to comment.