Skip to content

Commit

Permalink
Add tags to document type
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewCallis committed Nov 28, 2021
1 parent 1c00c94 commit ff92a5b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).

## [4.2.2](https://github.com/uttori/uttori-wiki/compare/v4.2.1...v4.2.2) - 2021-11-28

- 🧰 Add Support for Open Graph images on documents

## [4.2.1](https://github.com/uttori/uttori-wiki/compare/v4.2.0...v4.2.1) - 2021-11-28

- 🧰 Add Support for Open Graph images
Expand Down
10 changes: 9 additions & 1 deletion src/wiki.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const asyncHandler = (fn) => (request, response, next) => Promise.resolve(fn(req
* @property {string} [html] All rendered HTML content for the doucment that will be presented to the user.
* @property {number} createDate The Unix timestamp of the creation date of the document.
* @property {number} updateDate The Unix timestamp of the last update date to the document.
* @property {string[]} tags A collection of tags that represent the document.
* @property {string[]} [redirects] An array of slug like strings that will redirect to this document. Useful for renaming and keeping links valid or for short form WikiLinks.
*/

Expand Down Expand Up @@ -428,6 +429,7 @@ class UttoriWiki {
viewModel.title = `Search results for "${request.query.s}"`;
viewModel.searchTerm = query;

/** @type {UttoriWikiDocument[]} */
let searchResults = [];
try {
[searchResults] = await this.hooks.fetch('search-query', { query, limit: 50 }, this);
Expand Down Expand Up @@ -536,6 +538,7 @@ class UttoriWiki {
}

const { slug } = request.params;
/** @type {UttoriWikiDocument} */
let document;
try {
[document] = await this.hooks.fetch('storage-get', slug, this);
Expand Down Expand Up @@ -651,6 +654,7 @@ class UttoriWiki {
return;
}

/** @type {UttoriWikiDocument} */
let document;
try {
[document] = await this.hooks.fetch('storage-get', request.params.slug, this);
Expand Down Expand Up @@ -812,6 +816,7 @@ class UttoriWiki {
}

const { slug, revision } = request.params;
/** @type {UttoriWikiDocument} */
let document;
try {
[document] = await this.hooks.fetch('storage-get-revision', { slug, revision }, this);
Expand Down Expand Up @@ -875,6 +880,7 @@ class UttoriWiki {
}

const { slug, revision } = request.params;
/** @type {UttoriWikiDocument} */
let document;
try {
[document] = await this.hooks.fetch('storage-get-revision', { slug, revision }, this);
Expand Down Expand Up @@ -974,7 +980,7 @@ class UttoriWiki {
debug(`Updating with params: ${JSON.stringify(request.params, undefined, 2)}`);
debug(`Updating with body: ${JSON.stringify(request.body, undefined, 2)}`);

const { title = '', excerpt = '', content = '' } = request.body;
const { title = '', excerpt = '', content = '', image = '' } = request.body;

// Filter out any unwanted keys
const custom = this.config.allowedDocumentKeys.reduce((output, key) => {
Expand All @@ -991,9 +997,11 @@ class UttoriWiki {
let slug = request.body.slug || request.params.slug;
slug = slug.toLowerCase();

/** @type {UttoriWikiDocument} */
let document = {
...custom,
title,
image,
excerpt,
content,
tags,
Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ declare module "wiki" {
html?: string;
createDate: number;
updateDate: number;
tags: string[];
redirects?: string[];
};
}
Expand Down

0 comments on commit ff92a5b

Please sign in to comment.