mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
basic sitemap
This commit is contained in:
parent
57b69b36ee
commit
546fde0bf6
36
src/Components/AppShell/Sitemap.tsx
Normal file
36
src/Components/AppShell/Sitemap.tsx
Normal file
@ -0,0 +1,36 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useItems } from '../Map/hooks/useItems';
|
||||
|
||||
export const Sitemap = ({url}:{url:string}) => {
|
||||
const [sitemap, setSitemap] = useState('');
|
||||
|
||||
const items = useItems();
|
||||
|
||||
useEffect(() => {
|
||||
if (items.length) {
|
||||
const generateSitemap = () => {
|
||||
let sitemapXML = `<?xml version="1.0" encoding="UTF-8"?>\n`;
|
||||
sitemapXML += `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n`;
|
||||
|
||||
items.forEach(item => {
|
||||
sitemapXML += ` <url>\n`;
|
||||
sitemapXML += ` <loc>${url}/${item.slug}</loc>\n`;
|
||||
sitemapXML += ` </url>\n`;
|
||||
});
|
||||
|
||||
sitemapXML += `</urlset>`;
|
||||
return sitemapXML;
|
||||
};
|
||||
|
||||
setSitemap(generateSitemap());
|
||||
}
|
||||
}, [items]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>Sitemap</h1>
|
||||
<textarea value={sitemap} readOnly rows={items.length + 4} cols={80} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
export {AppShell} from "./AppShell"
|
||||
export {SideBar} from "./SideBar"
|
||||
export {Content} from "./Content"
|
||||
export {Content} from "./Content"
|
||||
export {Sitemap} from "./Sitemap"
|
||||
@ -1,5 +1,5 @@
|
||||
export { UtopiaMap, Layer, Tags, Permissions, ItemForm, ItemView, PopupTextAreaInput, PopupStartEndInput, PopupTextInput, PopupButton, TextView, StartEndView, PopupCheckboxInput } from './Components/Map';
|
||||
export {AppShell, Content, SideBar} from "./Components/AppShell"
|
||||
export {AppShell, Content, SideBar, Sitemap } from "./Components/AppShell"
|
||||
export {AuthProvider, useAuth, LoginPage, SignupPage, RequestPasswordPage, SetNewPasswordPage} from "./Components/Auth"
|
||||
export {UserSettings, ProfileSettings, OverlayProfile, OverlayProfileSettings, OverlayUserSettings, OverlayItemProfile, OverlayItemProfileSettings} from './Components/Profile'
|
||||
export {Quests, Modal} from './Components/Gaming'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user