Skip to content

Commit

Permalink
Merge branch 'directus-labs:main' into portal-account-page
Browse files Browse the repository at this point in the history
  • Loading branch information
omgitsjan authored Jul 24, 2024
2 parents 90ac92b + 019fd3c commit 47b1ec9
Show file tree
Hide file tree
Showing 4 changed files with 10,012 additions and 6,134 deletions.
64 changes: 39 additions & 25 deletions modules/directus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,38 +160,52 @@ export default defineNuxtModule({
const directus = createDirectus<Schema>(moduleOptions.rest.baseUrl).with(rest());

// Handle Redirects
const redirects = await directus.request(readItems('redirects'));
try {
const redirects = await directus.request(readItems('redirects'));

for (const redirect of redirects) {
let responseCode = redirect.response_code ? parseInt(redirect.response_code as any) : 301;

if (responseCode !== 301 && responseCode !== 302) {
responseCode = 301;
}

// Add the redirect to the route rules
// https://nuxt.com/docs/guide/concepts/rendering#route-rules
extendRouteRules(redirect.url_old as string, {
redirect: {
to: redirect.url_new,
statusCode: responseCode as 301 | 302,
},
});
}

for (const redirect of redirects) {
let responseCode = redirect.response_code ? parseInt(redirect.response_code as any) : 301;
log.success(`${redirects.length} Redirects loaded`);

if (responseCode !== 301 && responseCode !== 302) {
responseCode = 301;
for (const redirect of redirects) {
log.info(` • ${redirect.response_code}`, `From: ${redirect.url_old}`, `To: ${redirect.url_new}`);
}

// Add the redirect to the route rules
// https://nuxt.com/docs/guide/concepts/rendering#route-rules
extendRouteRules(redirect.url_old as string, {
redirect: {
to: redirect.url_new,
statusCode: responseCode as 301 | 302,
},
});
} catch (error) {
log.warn('Unable to load redirects due to the following error');
log.error(error);
log.warn(`Please ensure the directus instance is reachable at ${moduleOptions.rest.baseUrl}.`);
}

log.success(`${redirects.length} Redirects loaded`);

for (const redirect of redirects) {
log.info(` • ${redirect.response_code}`, `From: ${redirect.url_old}`, `To: ${redirect.url_new}`);
}
try {
// Add Globals
const globals = await directus.request<Omit<Globals, 'id' | 'url'>>(readSingleton('globals'));
nuxt.options.appConfig.globals = defu(nuxt.options.appConfig.globals, globals);
log.success('Globals loaded into appConfig');

// Add Globals
const globals = await directus.request<Omit<Globals, 'id' | 'url'>>(readSingleton('globals'));
nuxt.options.appConfig.globals = defu(nuxt.options.appConfig.globals, globals);
log.success('Globals loaded into appConfig');
// Add title template to the app head for use with useHead composable
nuxt.options.app.head.titleTemplate = `%s - ${globals?.title ?? 'Agency OS'}`;
} catch (error) {
nuxt.options.app.head.titleTemplate = '%s - Agency OS';

// Add title template to the app head for use with useHead composable
nuxt.options.app.head.titleTemplate = `%s - ${globals?.title ?? 'Agency OS'}`;
log.warn('Unable to load redirects due to the following error');
log.error(error);
log.warn(`Please ensure the directus instance is reachable at ${moduleOptions.rest.baseUrl}.`);
}

log.success(`Directus Module Loaded`);
},
Expand Down
6 changes: 3 additions & 3 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ export default defineNuxtConfig({
'@nuxt/ui',
'@nuxtjs/color-mode',
'@nuxtjs/google-fonts',
'@nuxtjs/sitemap', // https://nuxtseo.com/sitemap/getting-started/how-it-works
'@vueuse/motion/nuxt', // https://motion.vueuse.org/nuxt.html
'@vueuse/nuxt', // https://vueuse.org/
'nuxt-icon', // https://github.com/nuxt-modules/icon
'nuxt-og-image',
'nuxt-schema-org', // https://nuxtseo.com/schema-org/guides/quick-setup
'nuxt-simple-sitemap', // https://nuxtseo.com/sitemap/getting-started/how-it-works
],

experimental: {
Expand All @@ -52,7 +52,7 @@ export default defineNuxtConfig({
// Directus Configuration
directus: {
rest: {
baseUrl: process.env.DIRECTUS_URL,
baseUrl: process.env.DIRECTUS_URL || 'http://localhost:8055',
nuxtBaseUrl: process.env.NUXT_PUBLIC_SITE_URL || 'http://localhost:3000',
},
auth: {
Expand Down Expand Up @@ -97,7 +97,7 @@ export default defineNuxtConfig({
},

site: {
url: process.env.NUXT_PUBLIC_SITE_URL || 'http://localhost:3000',
url: process.env.SITE_URL || 'http://localhost:3000',
name: 'AgencyOS',
},

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@nuxtjs/eslint-config-typescript": "12.1.0",
"@nuxtjs/eslint-module": "4.1.0",
"@nuxtjs/google-fonts": "3.1.3",
"@nuxtjs/sitemap": "5.1.4",
"@nuxtjs/tailwindcss": "6.10.3",
"@stripe/stripe-js": "2.2.2",
"@tailwindcss/forms": "0.5.7",
Expand All @@ -40,10 +41,9 @@
"jwt-decode": "3.1.2",
"micromark": "4.0.0",
"micromark-extension-gfm": "3.0.0",
"nuxt": "3.9.1",
"nuxt": "3.10.3",
"nuxt-icon": "0.6.8",
"nuxt-schema-org": "3.3.2",
"nuxt-simple-sitemap": "3.4.0",
"prettier": "3.1.1",
"stripe": "13.8.0",
"typescript": "5.3.3",
Expand Down
Loading

0 comments on commit 47b1ec9

Please sign in to comment.