diff --git a/api/functions/graphql/nexus-typegen.ts b/api/functions/graphql/nexus-typegen.ts
index 9c435de..b0d01f0 100644
--- a/api/functions/graphql/nexus-typegen.ts
+++ b/api/functions/graphql/nexus-typegen.ts
@@ -665,7 +665,7 @@ export interface NexusGenArgTypes {
}
getFeed: { // args
skip?: number | null; // Int
- sortBy: string | null; // String
+ sortBy?: string | null; // String
take: number | null; // Int
topic?: number | null; // Int
}
diff --git a/api/functions/graphql/schema.graphql b/api/functions/graphql/schema.graphql
index 2c56478..3c67804 100644
--- a/api/functions/graphql/schema.graphql
+++ b/api/functions/graphql/schema.graphql
@@ -149,7 +149,7 @@ type Query {
getAllHackathons(sortBy: String, topic: Int): [Hackathon!]!
getCategory(id: Int!): Category!
getDonationsStats: DonationsStats!
- getFeed(skip: Int = 0, sortBy: String = "all", take: Int = 10, topic: Int = 0): [Post!]!
+ getFeed(skip: Int = 0, sortBy: String, take: Int = 10, topic: Int = 0): [Post!]!
getLnurlDetailsForProject(project_id: Int!): LnurlDetails!
getPostById(id: Int!, type: POST_TYPE!): Post!
getProject(id: Int!): Project!
diff --git a/api/functions/graphql/types/post.js b/api/functions/graphql/types/post.js
index 8bcd06c..a26088f 100644
--- a/api/functions/graphql/types/post.js
+++ b/api/functions/graphql/types/post.js
@@ -14,6 +14,7 @@ const { paginationArgs } = require('./helpers');
const { prisma } = require('../../../prisma');
const { getUserByPubKey } = require('../../../auth/utils/helperFuncs');
const { ApolloError } = require('apollo-server-lambda');
+const { marked } = require('marked');
const POST_TYPE = enumType({
@@ -189,7 +190,8 @@ const createStory = extendType({
// Preprocess & insert
- const excerpt = body.replace(/<[^>]+>/g, '').slice(0, 120);
+ const htmlBody = marked.parse(body);
+ const excerpt = htmlBody.replace(/<[^>]+>/g, '').slice(0, 120);
if (id)
return prisma.story.update({
@@ -395,9 +397,7 @@ const getFeed = extendType({
type: "Post",
args: {
...paginationArgs({ take: 10 }),
- sortBy: stringArg({
- default: "all"
- }), // all, popular, trending, newest
+ sortBy: stringArg(), // all, popular, trending, newest
topic: intArg({
default: 0
})
@@ -405,8 +405,15 @@ const getFeed = extendType({
resolve(_, { take, skip, topic, sortBy, }) {
+ let orderBy = { createdAt: "desc" };
+
+ if (sortBy === 'popular')
+ orderBy = { votes_count: 'desc' };
+ else if (sortBy === 'newest')
+ orderBy = { createdAt: "desc" };
+
return prisma.story.findMany({
- orderBy: { createdAt: "desc" },
+ orderBy: orderBy,
where: {
topic_id: topic ? topic : undefined,
},
diff --git a/public/assets/images/stw2.jfif b/public/assets/images/stw2.jfif
new file mode 100644
index 0000000..c54e9e0
Binary files /dev/null and b/public/assets/images/stw2.jfif differ
diff --git a/src/Components/Inputs/TextEditor/SaveModule.tsx b/src/Components/Inputs/TextEditor/SaveModule.tsx
index c7bbe93..af03581 100644
--- a/src/Components/Inputs/TextEditor/SaveModule.tsx
+++ b/src/Components/Inputs/TextEditor/SaveModule.tsx
@@ -18,7 +18,10 @@ export default function SaveModule(props: Props) {
const changeCallback = useDebouncedCallback(ctx => {
const { state } = ctx;
- onChange(getHTML(state));
+ const md = getMarkdown(state);
+ console.log(md);
+
+ onChange(md);
}, [], 500)
useRemirrorContext(changeCallback)
diff --git a/src/Components/Inputs/TextEditor/Toolbar/Toolbar.tsx b/src/Components/Inputs/TextEditor/Toolbar/Toolbar.tsx
index 265bbb5..999a1bb 100644
--- a/src/Components/Inputs/TextEditor/Toolbar/Toolbar.tsx
+++ b/src/Components/Inputs/TextEditor/Toolbar/Toolbar.tsx
@@ -9,17 +9,17 @@ export default function Toolbar() {
-
-
@@ -87,10 +88,10 @@ export default function NavDesktop() {