main #5
8
package-lock.json
generated
8
package-lock.json
generated
|
@ -32,6 +32,7 @@
|
||||||
"markdown-it": "^14.0.0",
|
"markdown-it": "^14.0.0",
|
||||||
"markdown-it-attrs": "^4.1.6",
|
"markdown-it-attrs": "^4.1.6",
|
||||||
"memfs": "^4.11.1",
|
"memfs": "^4.11.1",
|
||||||
|
"mime-types": "^2.1.35",
|
||||||
"multer": "^1.4.5-lts.1",
|
"multer": "^1.4.5-lts.1",
|
||||||
"ollama": "^0.5.8",
|
"ollama": "^0.5.8",
|
||||||
"playwright": "*",
|
"playwright": "*",
|
||||||
|
@ -49,6 +50,7 @@
|
||||||
"@types/luxon": "^3.4.2",
|
"@types/luxon": "^3.4.2",
|
||||||
"@types/markdown-it": "^14.1.1",
|
"@types/markdown-it": "^14.1.1",
|
||||||
"@types/markdown-it-attrs": "^4.1.3",
|
"@types/markdown-it-attrs": "^4.1.3",
|
||||||
|
"@types/mime-types": "^2.1.4",
|
||||||
"@types/multer": "^1.4.11",
|
"@types/multer": "^1.4.11",
|
||||||
"@types/node": "^20.0.0",
|
"@types/node": "^20.0.0",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
|
@ -2829,6 +2831,12 @@
|
||||||
"integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==",
|
"integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/mime-types": {
|
||||||
|
"version": "2.1.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/mime-types/-/mime-types-2.1.4.tgz",
|
||||||
|
"integrity": "sha512-lfU4b34HOri+kAY5UheuFMWPDOI+OPceBSHZKp69gEyTL/mmJ4cnU6Y/rlme3UL3GyOn6Y42hyIEw0/q8sWx5w==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/@types/ms": {
|
"node_modules/@types/ms": {
|
||||||
"version": "0.7.34",
|
"version": "0.7.34",
|
||||||
"resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz",
|
"resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz",
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
"markdown-it": "^14.0.0",
|
"markdown-it": "^14.0.0",
|
||||||
"markdown-it-attrs": "^4.1.6",
|
"markdown-it-attrs": "^4.1.6",
|
||||||
"memfs": "^4.11.1",
|
"memfs": "^4.11.1",
|
||||||
|
"mime-types": "^2.1.35",
|
||||||
"multer": "^1.4.5-lts.1",
|
"multer": "^1.4.5-lts.1",
|
||||||
"ollama": "^0.5.8",
|
"ollama": "^0.5.8",
|
||||||
"playwright": "*",
|
"playwright": "*",
|
||||||
|
@ -56,6 +57,7 @@
|
||||||
"@types/luxon": "^3.4.2",
|
"@types/luxon": "^3.4.2",
|
||||||
"@types/markdown-it": "^14.1.1",
|
"@types/markdown-it": "^14.1.1",
|
||||||
"@types/markdown-it-attrs": "^4.1.3",
|
"@types/markdown-it-attrs": "^4.1.3",
|
||||||
|
"@types/mime-types": "^2.1.4",
|
||||||
"@types/multer": "^1.4.11",
|
"@types/multer": "^1.4.11",
|
||||||
"@types/node": "^20.0.0",
|
"@types/node": "^20.0.0",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
|
|
|
@ -14,7 +14,8 @@ const { editToken, text } = Astro.props;
|
||||||
.content {
|
.content {
|
||||||
margin-bottom: 2rem;
|
margin-bottom: 2rem;
|
||||||
border: 1px solid rgba(var(--accent-light), 25%);
|
border: 1px solid rgba(var(--accent-light), 25%);
|
||||||
background: linear-gradient(rgba(var(--accent-dark), 66%), rgba(var(--accent-dark), 33%));
|
/* background: linear-gradient(rgba(var(--accent-dark), 66%), rgba(var(--accent-dark), 33%)); */
|
||||||
|
background-color: #13151a;
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
font-family: "Urbanist", sans-serif;
|
font-family: "Urbanist", sans-serif;
|
||||||
|
@ -24,3 +25,9 @@ const { editToken, text } = Astro.props;
|
||||||
a, a:link, a:visited { text-decoration: none; color: #fff }
|
a, a:link, a:visited { text-decoration: none; color: #fff }
|
||||||
a:hover { text-decoration: underline; color: #fff }
|
a:hover { text-decoration: underline; color: #fff }
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style is:inline>
|
||||||
|
.content img {
|
||||||
|
max-height: 12em;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -78,8 +78,8 @@ export const getWebhookPort = () => env.WEBHOOK_PORT ? parseInt(env.WEBHOOK_PORT
|
||||||
export const getSquidexAppName = () => env.SQUIDEX_APP_NAME || undefined;
|
export const getSquidexAppName = () => env.SQUIDEX_APP_NAME || undefined;
|
||||||
export const getSquidexClientId = () => env.SQUIDEX_CLIENT_ID || undefined;
|
export const getSquidexClientId = () => env.SQUIDEX_CLIENT_ID || undefined;
|
||||||
export const getSquidexClientSecret = () => env.SQUIDEX_CLIENT_SECRET || undefined;
|
export const getSquidexClientSecret = () => env.SQUIDEX_CLIENT_SECRET || undefined;
|
||||||
export const getSquidexEnvironment = () => env.SQUIDEX_ENVIRONMENT || undefined;
|
export const getSquidexEnvironment = () => trimSlashes(env.SQUIDEX_ENVIRONMENT||'') || undefined;
|
||||||
export const getSquidexPublicUrl = () => env.SQUIDEX_PUBLIC_URL || getSquidexEnvironment();
|
export const getSquidexPublicUrl = () => trimSlashes(env.SQUIDEX_PUBLIC_URL||'') || getSquidexEnvironment();
|
||||||
|
|
||||||
export const config: Config = {
|
export const config: Config = {
|
||||||
// AmazonProductAdvertisingAPIAccessKey: getAmazonProductAdvertisingAPIAccessKey(),
|
// AmazonProductAdvertisingAPIAccessKey: getAmazonProductAdvertisingAPIAccessKey(),
|
||||||
|
|
|
@ -3,4 +3,5 @@ import type { NonLocalized } from "../../internals/NonLocalizedT";
|
||||||
export interface Redirect {
|
export interface Redirect {
|
||||||
prevSlug: NonLocalized<string>,
|
prevSlug: NonLocalized<string>,
|
||||||
newContent: NonLocalized<string[]>,
|
newContent: NonLocalized<string[]>,
|
||||||
|
newContentSchema: NonLocalized<{ schemaName: string }[]>,
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
import markdownIt from "markdown-it";
|
import markdownIt from "markdown-it";
|
||||||
import markdownItAttrs from "markdown-it-attrs";
|
import markdownItAttrs from "markdown-it-attrs";
|
||||||
import vm from 'node:vm';
|
import vm from 'node:vm';
|
||||||
|
import { config } from "../config";
|
||||||
|
|
||||||
export const md = markdownIt().use(markdownItAttrs, {
|
export const md = markdownIt().use(markdownItAttrs, {
|
||||||
});
|
});
|
||||||
|
@ -67,9 +68,15 @@ const renderCodeblock = (lang: string, template: string, templateContext?: any)
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const replaceSquidexAssetPathWithOwn = (html: string) => {
|
||||||
|
let re = new RegExp(`src\\s*=\\s*["']${config.squidexPublicUrl?.replaceAll(`/`, `\\/`).replaceAll(`.`, `\\.`)||''}\\/api\\/assets/${config.squidexAppName||''}/([\\w-\\.\\/]*)["']`, 'g');
|
||||||
|
return html.replaceAll(re, `src="${config.siteUrl}/img/$1"`);
|
||||||
|
}
|
||||||
|
|
||||||
export const renderMarkdown = (template: string, templateContext?: any) => {
|
export const renderMarkdown = (template: string, templateContext?: any) => {
|
||||||
// render code blocks inside of the Markdown
|
// render code blocks inside of the Markdown
|
||||||
template = renderCodeblock('markdown', template, templateContext);
|
template = renderCodeblock('markdown', template, templateContext);
|
||||||
template = md.render(interpolateString(template, templateContext));
|
template = md.render(interpolateString(template, templateContext));
|
||||||
|
template = replaceSquidexAssetPathWithOwn(template);
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
|
@ -87,27 +87,24 @@ else {
|
||||||
const redirectDto = await getRedirectsByPreviousSlug(routeLookup!);
|
const redirectDto = await getRedirectsByPreviousSlug(routeLookup!);
|
||||||
console.log("redirectDto:", redirectDto);
|
console.log("redirectDto:", redirectDto);
|
||||||
if (redirectDto && redirectDto.items && redirectDto.items.length > 0) {
|
if (redirectDto && redirectDto.items && redirectDto.items.length > 0) {
|
||||||
console.log("getting redirectReferencesDto for", SCHEMAS.REDIRECTS, redirectDto.items[0].id);
|
console.log("getting redirectReferencesDto for", SCHEMAS.REDIRECTS, redirectDto.items[0].data?.newContentSchema[locale]);
|
||||||
|
// let objectId = redirectDto.items[0].data.newContent[locale];
|
||||||
//next line crashes:
|
//next line crashes:
|
||||||
let redirectReferencesDto = await client.contents.getReferences({ schema: SCHEMAS.REDIRECTS, id: redirectDto.items[0].id });
|
// let redirectReferencesDto = await client.contents.getReferences({ schema: SCHEMAS.REDIRECTS, id: redirectDto.items[0].id });
|
||||||
console.log("redirectReferencesDto:", redirectReferencesDto);
|
let schemaName = redirectDto.items[0].data?.newContentSchema[locale][0].schemaName;
|
||||||
|
let whicheverDto = await client.contents.getContent({schema: schemaName, id: redirectDto.items[0].data?.newContent[locale][0]});
|
||||||
|
// console.log("redirectReferencesDto:", redirectReferencesDto);
|
||||||
// client.contents.getConten
|
// client.contents.getConten
|
||||||
// switch (redirectDto.items[0].data?.referenceSchema.iv) {
|
switch (schemaName) {
|
||||||
// case SCHEMAS.BRANDS:
|
case SCHEMAS.BRANDS:
|
||||||
// return Astro.rewrite(`/view/brands/${locale}/${objectId}`);
|
case SCHEMAS.MARKETPLACES:
|
||||||
// case SCHEMAS.MARKETPLACES:
|
case SCHEMAS.PAGES:
|
||||||
// return Astro.rewrite(`/view/marketplaces/${locale}/${objectId}`);
|
case SCHEMAS.PRODUCT_CATEGORIES:
|
||||||
// case SCHEMAS.PAGES:
|
case SCHEMAS.PRODUCTS:
|
||||||
// return Astro.rewrite(`/view/pages/${locale}/${objectId}`);
|
case SCHEMAS.SELLERS:
|
||||||
// case SCHEMAS.PRODUCT_CATEGORIES:
|
Astro.response.headers.set('Vary', 'Accept-Language');
|
||||||
// return Astro.rewrite(`/view/product-categories/${locale}/${objectId}`);
|
return Astro.redirect(`/${whicheverDto.data.slug[locale]}`, 303);
|
||||||
// case SCHEMAS.PRODUCTS:
|
}
|
||||||
// return Astro.rewrite(`/view/products/${locale}/${objectId}`);
|
|
||||||
// case SCHEMAS.SELLERS:
|
|
||||||
// return Astro.rewrite(`/view/sellers/${locale}/${objectId}`);
|
|
||||||
// }
|
|
||||||
// Astro.response.headers.set('Vary', 'Accept-Language');
|
|
||||||
// return Astro.redirect(,303)
|
|
||||||
}
|
}
|
||||||
return redirect404NotFound();
|
return redirect404NotFound();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user