diff --git a/apps/component-doc-portal/project.json b/apps/component-doc-portal/project.json index 7cd5bcb..41a5ad5 100644 --- a/apps/component-doc-portal/project.json +++ b/apps/component-doc-portal/project.json @@ -1,123 +1,121 @@ -{ - "name": "component-doc-portal", - "$schema": "..\\..\\node_modules\\nx\\schemas\\project-schema.json", - "projectType": "application", - "sourceRoot": "apps/component-doc-portal/src", - "prefix": "component-doc-portal", - "targets": { - "compile": { - "executor": "@oasisdigital/ng-doc-portal-plugin:compile", - "options": { - "configFile": "apps/component-doc-portal/ng-doc-portal-config.json" - } - }, - "build": { - "executor": "@oasisdigital/ng-doc-portal-plugin:build", - "options": { - "configFile": "apps/component-doc-portal/ng-doc-portal-config.json" - }, - "configurations": { - "production": { - "ngConfigTarget": "production" - }, - "configuration": { - "ngConfigTarget": "development" - } - } - }, - "serve": { - "executor": "@oasisdigital/ng-doc-portal-plugin:serve", - "options": { - "configFile": "apps/component-doc-portal/ng-doc-portal-config.json" - }, - "configurations": { - "production": { - "ngConfigTarget": "production" - }, - "configuration": { - "ngConfigTarget": "development" - } - } - }, - "extract-i18n": { - "executor": "nx:run-commands", - "options": { - "commands": [ - { - "command": "npx nx compile component-doc-portal", - "forwardAllArgs": false - }, - { - "command": "npx nx ng-extract-i18n component-doc-portal" - } - ], - "parallel": false - } - }, - "ng-build": { - "executor": "@angular-devkit/build-angular:browser", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/apps/component-doc-portal", - "index": "apps/component-doc-portal/src/index.html", - "main": "apps/component-doc-portal/src/main.ts", - "polyfills": "apps/component-doc-portal/src/polyfills.ts", - "tsConfig": "apps/component-doc-portal/tsconfig.app.json", - "inlineStyleLanguage": "scss", - "assets": [ - "apps/component-doc-portal/src/favicon.ico", - "apps/component-doc-portal/src/assets" - ], - "styles": [ - "libs/ng-doc-portal/src/lib/styles/milligram.scss", - "libs/ng-doc-portal/src/lib/styles/ng-doc-portal.scss", - "apps/component-doc-portal/src/styles.scss" - ], - "scripts": [] - }, - "configurations": { - "production": { - "outputHashing": "all" - }, - "development": { - "buildOptimizer": false, - "optimization": false, - "vendorChunk": true, - "extractLicenses": false, - "sourceMap": true, - "namedChunks": true - } - }, - "defaultConfiguration": "production" - }, - "ng-serve": { - "executor": "@angular-devkit/build-angular:dev-server", - "configurations": { - "production": { - "buildTarget": "component-doc-portal:ng-build:production" - }, - "development": { - "buildTarget": "component-doc-portal:ng-build:development" - } - }, - "defaultConfiguration": "development" - }, - "ng-extract-i18n": { - "executor": "@angular-devkit/build-angular:extract-i18n", - "options": { - "buildTarget": "component-doc-portal:ng-build" - } - }, - "lint": { - "executor": "@nx/eslint:lint" - }, - "test": { - "executor": "@nx/jest:jest", - "outputs": ["{workspaceRoot}/coverage/apps/component-doc-portal"], - "options": { - "jestConfig": "apps/component-doc-portal/jest.config.ts" - } - } - }, - "tags": [] -} +{ + "name": "component-doc-portal", + "$schema": "..\\..\\node_modules\\nx\\schemas\\project-schema.json", + "projectType": "application", + "sourceRoot": "apps/component-doc-portal/src", + "prefix": "component-doc-portal", + "targets": { + "compile": { + "executor": "@oasisdigital/ng-doc-portal-plugin:compile", + "options": { + "configFile": "apps/component-doc-portal/ng-doc-portal-config.json" + } + }, + "build": { + "executor": "@oasisdigital/ng-doc-portal-plugin:build", + "options": { + "configFile": "apps/component-doc-portal/ng-doc-portal-config.json" + }, + "configurations": { + "production": { + "ngConfigTarget": "production" + }, + "configuration": { + "ngConfigTarget": "development" + } + } + }, + "serve": { + "executor": "@oasisdigital/ng-doc-portal-plugin:serve", + "options": { + "configFile": "apps/component-doc-portal/ng-doc-portal-config.json" + }, + "configurations": { + "production": { + "ngConfigTarget": "production" + }, + "configuration": { + "ngConfigTarget": "development" + } + } + }, + "extract-i18n": { + "executor": "nx:run-commands", + "options": { + "commands": [ + { + "command": "npx nx compile component-doc-portal", + "forwardAllArgs": false + }, + { + "command": "npx nx ng-extract-i18n component-doc-portal" + } + ], + "parallel": false + } + }, + "ng-build": { + "executor": "@angular-devkit/build-angular:application", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/apps/component-doc-portal", + "index": "apps/component-doc-portal/src/index.html", + "browser": "apps/component-doc-portal/src/main.ts", + "polyfills": ["zone.js"], + "tsConfig": "apps/component-doc-portal/tsconfig.app.json", + "inlineStyleLanguage": "scss", + "assets": [ + "apps/component-doc-portal/src/favicon.ico", + "apps/component-doc-portal/src/assets" + ], + "styles": [ + "libs/ng-doc-portal/src/lib/styles/milligram.scss", + "libs/ng-doc-portal/src/lib/styles/ng-doc-portal.scss", + "apps/component-doc-portal/src/styles.scss" + ], + "scripts": [] + }, + "configurations": { + "production": { + "outputHashing": "all" + }, + "development": { + "optimization": false, + "extractLicenses": false, + "sourceMap": true, + "namedChunks": true + } + }, + "defaultConfiguration": "production" + }, + "ng-serve": { + "executor": "@angular-devkit/build-angular:dev-server", + "configurations": { + "production": { + "buildTarget": "component-doc-portal:ng-build:production" + }, + "development": { + "buildTarget": "component-doc-portal:ng-build:development" + } + }, + "defaultConfiguration": "development" + }, + "ng-extract-i18n": { + "executor": "@angular-devkit/build-angular:extract-i18n", + "options": { + "buildTarget": "component-doc-portal:ng-build" + } + }, + "lint": { + "executor": "@nx/eslint:lint" + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/apps/component-doc-portal"], + "options": { + "jestConfig": "apps/component-doc-portal/jest.config.ts" + } + } + }, + "tags": [] +} diff --git a/apps/component-doc-portal/src/polyfills.ts b/apps/component-doc-portal/src/polyfills.ts deleted file mode 100644 index e4555ed..0000000 --- a/apps/component-doc-portal/src/polyfills.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * This file includes polyfills needed by Angular and is loaded before the app. - * You can add your own extra polyfills to this file. - * - * This file is divided into 2 sections: - * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. - * 2. Application imports. Files imported after ZoneJS that should be loaded before your main - * file. - * - * The current setup is for so-called "evergreen" browsers; the last versions of browsers that - * automatically update themselves. This includes recent versions of Safari, Chrome (including - * Opera), Edge on the desktop, and iOS and Chrome on mobile. - * - * Learn more in https://angular.io/guide/browser-support - */ - -/*************************************************************************************************** - * BROWSER POLYFILLS - */ - -/** - * By default, zone.js will patch all possible macroTask and DomEvents - * user can disable parts of macroTask/DomEvents patch by setting following flags - * because those flags need to be set before `zone.js` being loaded, and webpack - * will put import in the top of bundle, so user need to create a separate file - * in this directory (for example: zone-flags.ts), and put the following flags - * into that file, and then add the following code before importing zone.js. - * import './zone-flags'; - * - * The flags allowed in zone-flags.ts are listed here. - * - * The following flags will work for all browsers. - * - * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame - * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick - * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames - * - * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js - * with the following flag, it will bypass `zone.js` patch for IE/Edge - * - * (window as any).__Zone_enable_cross_context_check = true; - * - */ - -/*************************************************************************************************** - * Zone JS is required by default for Angular itself. - */ -import 'zone.js'; // Included with Angular CLI. - -/*************************************************************************************************** - * APPLICATION IMPORTS - */ diff --git a/apps/component-doc-portal/tsconfig.app.json b/apps/component-doc-portal/tsconfig.app.json index 6b0a77d..2c19845 100644 --- a/apps/component-doc-portal/tsconfig.app.json +++ b/apps/component-doc-portal/tsconfig.app.json @@ -6,7 +6,7 @@ "target": "ES2022", "useDefineForClassFields": false }, - "files": ["src/main.ts", "src/polyfills.ts"], + "files": ["src/main.ts"], "include": ["src/**/*.d.ts"], "exclude": [ "**/*.test.ts", diff --git a/libs/ng-doc-portal-plugin/src/executors/compiler/util.ts b/libs/ng-doc-portal-plugin/src/executors/compiler/util.ts index a6237ec..399c3c5 100644 --- a/libs/ng-doc-portal-plugin/src/executors/compiler/util.ts +++ b/libs/ng-doc-portal-plugin/src/executors/compiler/util.ts @@ -209,7 +209,6 @@ export async function extractTitleFromDocPageFile( ) { const title = await getTitleFromTypeScript(filePath); const prefix = findTitlePrefixFromGlobPatterns(filePath, globPatterns); - if (prefix) { return `${prefix}/${title}`; } else { @@ -226,20 +225,11 @@ export async function extractTitleFromDocPageFile( export function generateDocPageLoader(filePath: string, title: string) { // Figure out variables for config list file output const filePathWithoutExtension = filePath.replace('.ts', ''); - /* If nested folders are used */ - const nestedPathCount = ( - filePathWithoutExtension.split('/src')[0].split('apps/')[1].match(/\//g) || - [] - ).length; const route = title.toLowerCase().replace(/[ /]/g, '-'); - let startingPath = '../../../../'; - for (let index = 0; index < nestedPathCount; index++) { - startingPath += '../'; - } return ` '${route}': { title: '${title}', - fetch: () => import('${startingPath}${filePathWithoutExtension}').then((file) => file.default) + fetch: () => import('../../../../${filePathWithoutExtension}').then((file) => file.default) } `; } @@ -264,6 +254,7 @@ export async function formatContent(content: string): Promise { */ export function wrapTypescriptBoilerplate(configStrings: string[]) { return ` + /* eslint-disable */ import { DocPageLoaderRecord } from '@oasisdigital/ng-doc-portal'; export const docPageLoaders: DocPageLoaderRecord = { diff --git a/libs/ng-doc-portal-plugin/src/generators/doc-page/files/__className__.doc-page.ts__tmpl__ b/libs/ng-doc-portal-plugin/src/generators/doc-page/files/__className__.doc-page.ts__tmpl__ index fdbbabf..e58de57 100644 --- a/libs/ng-doc-portal-plugin/src/generators/doc-page/files/__className__.doc-page.ts__tmpl__ +++ b/libs/ng-doc-portal-plugin/src/generators/doc-page/files/__className__.doc-page.ts__tmpl__ @@ -1,27 +1,19 @@ -import { Component, NgModule } from '@angular/core'; - -import { DocPageConfig } from '@oasisdigital/ng-doc-portal'; - -@Component({ - template: ` -

Starting template for <%= className %>

- - `, -}) -export class <%= className %>DocumentPageComponent {} - -// This can probably go away when Optional Modules is in Angular -@NgModule({ - declarations: [], - imports: [], - providers: [], -}) -export class DocumentPageModule {} - -const docPageConfig: DocPageConfig = { - title: '<%= path %><%= className %>', - docPageComponent: <%= className %>DocumentPageComponent, - ngModule: DocumentPageModule, -}; - -export default docPageConfig; +import { Component, NgModule } from '@angular/core'; + +import { DocPageConfig } from '@oasisdigital/ng-doc-portal'; + +@Component({ + standalone:true, + template: ` +

Starting template for <%= className %>

+ + `, +}) +export class <%= className %>DocumentPageComponent {} + +const docPageConfig: DocPageConfig = { + title: '<%= path %><%= className %>', + component: <%= className %>DocumentPageComponent +}; + +export default docPageConfig; diff --git a/libs/ng-doc-portal/src/lib/styles/components/general/code-snippet.scss b/libs/ng-doc-portal/src/lib/styles/components/general/code-snippet.scss index aeded11..f4b3645 100644 --- a/libs/ng-doc-portal/src/lib/styles/components/general/code-snippet.scss +++ b/libs/ng-doc-portal/src/lib/styles/components/general/code-snippet.scss @@ -1,4 +1,4 @@ -@import '~highlight.js/styles/github.css'; +@import 'highlight.js/styles/github.css'; ngdp-code-snippet { div.hljs {