Skip to content

Commit

Permalink
Merge pull request #154 from thegalactiks/refactor-contentlayer
Browse files Browse the repository at this point in the history
refactor: move document types in a dedicated dir and add example dir
  • Loading branch information
emmanuelgautier authored Feb 13, 2024
2 parents 9dfdbbf + dc3aa08 commit b55f19c
Show file tree
Hide file tree
Showing 47 changed files with 866 additions and 512 deletions.
3 changes: 3 additions & 0 deletions examples/contentlayer/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["plugin:mdx/recommended"]
}
21 changes: 21 additions & 0 deletions examples/contentlayer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# dependencies
node_modules/

# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# environment variables
.env
.env.production

# macOS-specific files
.DS_Store

# eslint
.eslintcache

# Contentlayer
.contentlayer
Empty file.
Empty file.
17 changes: 17 additions & 0 deletions examples/contentlayer/content/articles/article.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Article name
description: Article description
identifier: article
author: person
dateCreated: 1970-01-01
dateModified: 1970-01-01
datePublished: 1970-01-01
keywords:
- keyword
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

## de Finibus Bonorum et Malorum

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
7 changes: 7 additions & 0 deletions examples/contentlayer/content/elements/navbar.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
elementType: SiteNavigationElement
identifier: navbar
itemListElement:
- name: Homepage
path: /
---
7 changes: 7 additions & 0 deletions examples/contentlayer/content/organizations/organization.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: Organization name
description: Organization description
identifier: organization
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
8 changes: 8 additions & 0 deletions examples/contentlayer/content/pages/homepage.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: Homepage
description: Homepage description
identifier: index
dateCreated: 1970-01-01
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
8 changes: 8 additions & 0 deletions examples/contentlayer/content/pages/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: Page title
description: Page description
identifier: page
dateCreated: 1970-01-01
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
8 changes: 8 additions & 0 deletions examples/contentlayer/content/persons/person.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: Person name
description: Person description
identifier: person
dateCreated: 1970-01-01
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
8 changes: 8 additions & 0 deletions examples/contentlayer/content/places/place.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: Place name
description: Place description
identifier: place
dateCreated: 1970-01-01
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
7 changes: 7 additions & 0 deletions examples/contentlayer/content/websites/example.com.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: Website name
description: Website description.
identifier: example.com
url: https://example.com/
dateCreated: 1970-01-01
---
27 changes: 27 additions & 0 deletions examples/contentlayer/contentlayer.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {
ArticleDocumentType,
OrganizationDocumentType,
PageDocumentType,
PersonDocumentType,
PlaceDocumentType,
WebsiteDocumentType,
WebpageElementDocumentType,
} from '@galactiks/contentlayer';
import { makeSource } from 'contentlayer/source-files';

const contentLayerConfig = makeSource({
contentDirPath: 'content',
documentTypes: [
ArticleDocumentType,
OrganizationDocumentType,
PageDocumentType,
PersonDocumentType,
PlaceDocumentType,
WebsiteDocumentType,
WebpageElementDocumentType,
],
mdx: {},
disableImportAliasWarning: true,
});

export default contentLayerConfig;
7 changes: 7 additions & 0 deletions examples/contentlayer/galactiks.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"template": "",
"locales": {
"default": "en",
"available": ["en"]
}
}
20 changes: 20 additions & 0 deletions examples/contentlayer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@galactiks/contentlayer-example",
"version": "0.0.0",
"description": "Contentlayer repository example.",
"private": "true",
"scripts": {
"build": "contentlayer build",
"lint": "eslint . --ext mdx --cache"
},
"dependencies": {
"@galactiks/contentlayer": "workspace:^",
"contentlayer": "0.3.4"
},
"devDependencies": {
"eslint": "8.56.0",
"eslint-plugin-mdx": "3.1.5",
"react": "18.2.0",
"react-dom": "18.2.0"
}
}
Empty file.
6 changes: 6 additions & 0 deletions examples/contentlayer/webmanifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "",
"description": "",
"start_url": "",
"icons": []
}
3 changes: 2 additions & 1 deletion packages/adapters/astro/src/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import Debug from 'debug';
const debug = Debug('@galactiks/astro-integration:sitemap');

export const sitemapSerialize =
() => async (item: SitemapItem): Promise<SitemapItem | undefined> => {
() =>
async (item: SitemapItem): Promise<SitemapItem | undefined> => {
debug('serializing item', item);

const page = await getPageByURL(item.url);
Expand Down
1 change: 0 additions & 1 deletion packages/contentlayer/src/configs/index.ts

This file was deleted.

52 changes: 0 additions & 52 deletions packages/contentlayer/src/configs/source-files.config.ts

This file was deleted.

25 changes: 25 additions & 0 deletions packages/contentlayer/src/consts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { DocumentTypeDef as ContentlayerDocumentTypeDef } from 'contentlayer/source-files';

export enum pageDocumentTypes {
Article = 'articles',
Organization = 'organizations',
Page = 'pages',
Person = 'people',
Place = 'place',
Tag = 'tags',
}

export enum documentTypes {
Article = pageDocumentTypes.Article,
Organization = pageDocumentTypes.Organization,
Page = pageDocumentTypes.Page,
Person = pageDocumentTypes.Person,
Place = pageDocumentTypes.Place,
Tag = pageDocumentTypes.Tag,
WebPageElement = 'webPageElements',
Website = 'websites',
}

export type DocumentTypeDef = ContentlayerDocumentTypeDef & {
name: keyof typeof documentTypes;
};
8 changes: 8 additions & 0 deletions packages/contentlayer/src/document-types/article.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineDocumentType } from 'contentlayer/source-files';
import { ContentLayerArticleFields } from '../fields/article.js';

export const ArticleDocumentType = defineDocumentType(() => ({
...ContentLayerArticleFields,
filePathPattern: 'articles/**/*.md?(x)',
contentType: 'mdx',
}));
Empty file.
8 changes: 8 additions & 0 deletions packages/contentlayer/src/document-types/organization.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineDocumentType } from 'contentlayer/source-files';
import { ContentLayerOrganizationFields } from '../fields/organization.js';

export const OrganizationDocumentType = defineDocumentType(() => ({
...ContentLayerOrganizationFields,
filePathPattern: 'organizations/**/*.md?(x)',
contentType: 'mdx',
}));
8 changes: 8 additions & 0 deletions packages/contentlayer/src/document-types/page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineDocumentType } from 'contentlayer/source-files';
import { ContentLayerPageFields } from '../fields/page.js';

export const PageDocumentType = defineDocumentType(() => ({
...ContentLayerPageFields,
filePathPattern: 'pages/**/*.md?(x)',
contentType: 'mdx',
}));
8 changes: 8 additions & 0 deletions packages/contentlayer/src/document-types/person.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineDocumentType } from 'contentlayer/source-files';
import { ContentLayerPersonFields } from '../fields/person.js';

export const PersonDocumentType = defineDocumentType(() => ({
...ContentLayerPersonFields,
filePathPattern: 'persons/**/*.md?(x)',
contentType: 'mdx',
}));
8 changes: 8 additions & 0 deletions packages/contentlayer/src/document-types/place.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineDocumentType } from 'contentlayer/source-files';
import { ContentLayerPlaceFields } from '../fields/place.js';

export const PlaceDocumentType = defineDocumentType(() => ({
...ContentLayerPlaceFields,
filePathPattern: 'places/**/*.md?(x)',
contentType: 'mdx',
}));
8 changes: 8 additions & 0 deletions packages/contentlayer/src/document-types/webpage-element.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineDocumentType } from 'contentlayer/source-files';
import { ContentLayerWebPageElementFields } from '../fields/webpage-element.js';

export const WebpageElementDocumentType = defineDocumentType(() => ({
...ContentLayerWebPageElementFields,
filePathPattern: 'elements/**/*.md?(x)',
contentType: 'mdx',
}));
8 changes: 8 additions & 0 deletions packages/contentlayer/src/document-types/website.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineDocumentType } from 'contentlayer/source-files';
import { ContentLayerWebsiteFields } from '../fields/website.js';

export const WebsiteDocumentType = defineDocumentType(() => ({
...ContentLayerWebsiteFields,
filePathPattern: 'websites/**/*.md?(x)',
contentType: 'mdx',
}));
Loading

0 comments on commit b55f19c

Please sign in to comment.