generate sitemap
This commit is contained in:
parent
e2b283f729
commit
35a093c14d
|
@ -56,6 +56,7 @@ export default async function publish(): Promise<PublishDictionaryResponse> {
|
||||||
entries,
|
entries,
|
||||||
};
|
};
|
||||||
uploadDictionaryToStorage(dictionary).catch(console.error);
|
uploadDictionaryToStorage(dictionary).catch(console.error);
|
||||||
|
uploadSitemap(dictionary).catch(console.error);
|
||||||
// TODO: make this async and run after publish response
|
// TODO: make this async and run after publish response
|
||||||
doHunspellEtc(dictionary.info, entries).catch(console.error);
|
doHunspellEtc(dictionary.info, entries).catch(console.error);
|
||||||
return {
|
return {
|
||||||
|
@ -254,6 +255,10 @@ async function uploadAllWordsToStoarage(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function uploadSitemap(dictionary: T.Dictionary) {
|
||||||
|
await upload(makeSitemap(dictionary), "sitemap.xml");
|
||||||
|
}
|
||||||
|
|
||||||
async function uploadDictionaryToStorage(dictionary: T.Dictionary) {
|
async function uploadDictionaryToStorage(dictionary: T.Dictionary) {
|
||||||
const dictionaryBuffer = writeDictionary(dictionary);
|
const dictionaryBuffer = writeDictionary(dictionary);
|
||||||
const dictionaryInfoBuffer = writeDictionaryInfo(dictionary.info);
|
const dictionaryInfoBuffer = writeDictionaryInfo(dictionary.info);
|
||||||
|
@ -268,6 +273,19 @@ async function uploadDictionaryToStorage(dictionary: T.Dictionary) {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function makeSitemap(dictionary: T.Dictionary): string {
|
||||||
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
|
${dictionary.entries.map(
|
||||||
|
(entry) =>
|
||||||
|
` <url>
|
||||||
|
<loc>https://dictionary.lingdocs.com/word?id=${entry.ts}</loc>
|
||||||
|
</url>`
|
||||||
|
)}
|
||||||
|
</urlset>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
// function makeHunspell(wordlist: string[]) {
|
// function makeHunspell(wordlist: string[]) {
|
||||||
// return {
|
// return {
|
||||||
// dicContent: wordlist.reduce((acc, word) => acc + word + "\n", wordlist.length + "\n"),
|
// dicContent: wordlist.reduce((acc, word) => acc + word + "\n", wordlist.length + "\n"),
|
||||||
|
|
Loading…
Reference in New Issue