diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2d37134..c3344d4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,15 @@ yarn compile ## Ember -``` +```bash cd packages/ember yarn start ``` + +## Core + +```bash +cd packages/core +# yarn test --watch for watch mode +yarn test +``` diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 8fcf3ab..c00afff 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -247,6 +247,7 @@ class Docfy { title, editUrl, relativeUrl: undefined, + relativePath, headings: [], frontmatter: frontmatter, pluginData: {}, diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index a11bb07..324160f 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -18,6 +18,7 @@ export interface Heading { export interface PageMetadata { url: string; relativeUrl: undefined | string; + relativePath: string; editUrl: string; title: string; headings: Heading[]; diff --git a/packages/core/tests/__snapshots__/integration-nested-page-metadata.test.ts.snap b/packages/core/tests/__snapshots__/integration-nested-page-metadata.test.ts.snap index f661af1..1a284cf 100644 --- a/packages/core/tests/__snapshots__/integration-nested-page-metadata.test.ts.snap +++ b/packages/core/tests/__snapshots__/integration-nested-page-metadata.test.ts.snap @@ -22,6 +22,7 @@ Object { "headings": Array [], "parentLabel": "components", "pluginData": Object {}, + "relativePath": "packages/package1/components/button.md", "relativeUrl": "button", "title": "Button Component", "url": "/docs/category1/components/button", @@ -36,6 +37,7 @@ Object { "headings": Array [], "parentLabel": "components", "pluginData": Object {}, + "relativePath": "packages/package1/components/form/index.md", "relativeUrl": "form", "title": "Form Component", "url": "/docs/category1/components/form", @@ -50,6 +52,7 @@ Object { "headings": Array [], "parentLabel": "components", "pluginData": Object {}, + "relativePath": "packages/package1/components/form/something-else.md", "relativeUrl": "something-else", "title": "something-else", "url": "/docs/category1/components/something-else", @@ -68,6 +71,7 @@ Object { "headings": Array [], "parentLabel": "category1", "pluginData": Object {}, + "relativePath": "packages/package1/docs/intro.md", "relativeUrl": "intro", "title": "Docs Intro", "url": "/docs/category1/intro", @@ -89,6 +93,7 @@ Object { "headings": Array [], "parentLabel": "category2", "pluginData": Object {}, + "relativePath": "packages/package2/docs/overview.md", "relativeUrl": "overview", "title": "Overview", "url": "/docs/category2/overview", @@ -102,6 +107,7 @@ Object { "headings": Array [], "parentLabel": "category2", "pluginData": Object {}, + "relativePath": "packages/package2/docs/styles.md", "relativeUrl": "styles", "title": "How styles work", "url": "/docs/category2/styles", @@ -121,6 +127,7 @@ Object { "headings": Array [], "parentLabel": "test-custom", "pluginData": Object {}, + "relativePath": "docs/custom-url.md", "relativeUrl": "url", "title": "This a test for the ability to change the url using frontmatter", "url": "/docs/test-custom/url", @@ -139,6 +146,7 @@ Object { "headings": Array [], "parentLabel": "docs", "pluginData": Object {}, + "relativePath": "README.md", "relativeUrl": "", "title": "The index", "url": "/docs/", @@ -151,6 +159,7 @@ Object { "headings": Array [], "parentLabel": "docs", "pluginData": Object {}, + "relativePath": "docs/how-it-works.md", "relativeUrl": "how-it-works", "title": "How it works?", "url": "/docs/how-it-works", @@ -184,6 +193,7 @@ Object { ], "parentLabel": "docs", "pluginData": Object {}, + "relativePath": "docs/about.md", "relativeUrl": "about", "title": "About the project", "url": "/docs/about", @@ -194,6 +204,7 @@ Object { "headings": Array [], "parentLabel": "docs", "pluginData": Object {}, + "relativePath": "docs/html.md", "relativeUrl": "html", "title": "HTML should work", "url": "/docs/html", @@ -204,6 +215,7 @@ Object { "headings": Array [], "parentLabel": "docs", "pluginData": Object {}, + "relativePath": "docs/math.md", "relativeUrl": "math", "title": "Testing math remark and rehype plugins", "url": "/docs/math", @@ -214,6 +226,7 @@ Object { "headings": Array [], "parentLabel": "docs", "pluginData": Object {}, + "relativePath": "docs/static-asset.md", "relativeUrl": "static-asset", "title": "This is a markdown that has a image", "url": "/docs/static-asset", @@ -224,6 +237,7 @@ Object { "headings": Array [], "parentLabel": "docs", "pluginData": Object {}, + "relativePath": "docs/table.md", "relativeUrl": "table", "title": "Table example", "url": "/docs/table", diff --git a/packages/ember/docs/components/docfy-output-demo/edit-page.md b/packages/ember/docs/components/docfy-output-demo/edit-page.md index facf604..7561af0 100644 --- a/packages/ember/docs/components/docfy-output-demo/edit-page.md +++ b/packages/ember/docs/components/docfy-output-demo/edit-page.md @@ -20,3 +20,35 @@ repository URL as well as the branch to edit. {{/if}} ``` + +For this to work, you need to include `repository` in your docfy-config: + +```js +// in your docfy-config.js +module.exports = { + repository: { + url: 'https://github.com/@username/repo-name', + editBranch: 'main', + }, + ...// rest of your config +} +``` + + +## Enterprise (aka on premise) git services + +`page.editUrl` works for Github, Bitbucket, Gitlab and Sourcehut. + +For on-premise instances git solutions (i.e. on-premise Gitlab, or on-premise Bitbucket), we expose the `page.relativePath` so that you might construct your own custom editUrl: + +```hbs + + {{#if page.relativePath}} + + {{/if}} + +``` + +Note: the edit url for your on-premise instance might be more complex than the example above. But the `page.relativePath` will give you the relative path to that file in your repo.