Internal refactoring #54
Replies: 10 comments 37 replies
-
There are many assumptions in the code. One of the examples: const image = resolvedImage?.replace('/images/', '/api/outstatic/images/') assumes images are in the We need to turn those assumptions into facts ie. extract this duplicated information into constants. |
Beta Was this translation helpful? Give feedback.
-
Having GitHub's GraphQL calls on the client causes a flash of content and lots of rerenders, that are especially annoying as the GitHub API is slow af. Move all API calls to the server? |
Beta Was this translation helpful? Give feedback.
-
Next 13 introduces Server Components. Should we look into those? |
Beta Was this translation helpful? Give feedback.
-
Having every file called index.ts is hard to work on IMO. I would suggest renaming files: // change this
DocumentSettings/
index.tsx
test.tsx
// to this
DocumentSettings.tsx
DocumentSettings.test.tsx |
Beta Was this translation helpful? Give feedback.
-
Some files are not ran through Prettier. I would move Prettier to ESLint for easier setup. This requires to run just ESLint, to both format and lint. It's easier to setup and to maintain (as all stylistic rules, file whitelists, etc. are in just one tool/config). |
Beta Was this translation helpful? Give feedback.
-
Hi @DCzajkowski, |
Beta Was this translation helpful? Give feedback.
-
Hi, i'm going to be referencing TinaCMS a bit because I had experience using that CMS on its baby steps, please bear with me. One of the first problems was related to how to handle all content with FS calls (that could be used via GitHub API) for very large projects, I think that the solution by @jakobo in #53 is the way to go and should improve performance in multiple scenarios and enable new use cases, like i18n. I think we should decouple the editor/UI part of Outstatic from the content layer and authentication to avoid vendor Lock-in. Right now using GitHub is really easy and great for Outstatic to get known, but not everyone is able or willing to use GitHub. I'm thinking about defining well thought interfaces so the content part of the GitHub API is easily replaced with other implementations (GitLab, Sourcehut, Redis cache, private client implementation). With this I don't mean to completely change the way Outstatic works with the content structure in the FS or limit that in any way, but to interface those calls for what Outstatic really wants, and be able to provide a different implementation, for example, store TEXT with METADATA could be easily be done on Redis, with the Matadata DB also being stored on Redis. The same for listing collections, etc. TinaCMS started with this approach but abandoned it years ago in favor of using TinaCloud and getting control of the backend. They just announced pricing plans and people are not happy to say the least. This plugable approach to the content backend may be necessary for some clients, since some sites may reach GitHub rate limits. Having options is a really nice ofering for open source projects. But GitHub is not used only for content, it's also used for authentication, which in the current state is really helpful for an easy set up (also development). But we can't count for every content backend to also implement auth since it may not make sense. We should decouple auth from content. |
Beta Was this translation helpful? Give feedback.
-
Dealing with monoreposContextHi everyone, I am benchmarking things, and I need something working like a "standalone" MDX editor. Problem 1 : untimely commit / pushNow, our application is looking like that, it's a turborepo monorepo:
→ Studio can be When we are editing things during local development, we don't want commit / push all the monorepo at each edit. Studio will be used in local to write documentation MD, and will be used in production for blog posts. Problem 2 ; We have our own CI/CD, we don't want to work with Outstatic default Github workflow
Can we disable this and just keep the changes in the MDX: things will be handled by our own push / webhooks ? Thx for your time ✌️ ! |
Beta Was this translation helpful? Give feedback.
-
Eliminate mutations and "clever" code. Mutations usually are a cause of bugs. My suggestion is to replace all mutating code with non-mutating. There are places where mutation might be required, but I think this is very rare. In some places there is also "clever", not-very-clear-what-it-does code. I think that should be eliminated to make the code easier to understand. As an example I will take first six lines of const meta = Object.entries(
(({ content, publishedAt, ...meta }) => meta)(data)
)
if (data.publishedAt) {
meta.push(['publishedAt', data.publishedAt.toISOString()])
} That could be rewritten to: const dataWithPublishedAt = {
...data,
...(data.publishedAt ? { publishedAt: data.publishedAt.toISOString() } : {})
}
const meta = Object.entries(omit(dataWithPublishedAt, ['content'])) BTW, in this code example, |
Beta Was this translation helpful? Give feedback.
-
What is the reason for turning off react/jsx-keys rule @avitorio? I think it should be turned back on |
Beta Was this translation helpful? Give feedback.
-
While adapting Outstatic to our needs, we have found, the code is written with a lot of indirection, assumptions, and coupling. While that's ok for an early prototype, if we want to introduce more customizability/plugins, this should be thought about and worked on.
I am creating this discussion to keep track of which refactorings @avitorio is comfortable with and which of those should be worked on.
I am creating a thread for every thing I though of when working on Outstatic. Please PR only those refactorings @avitorio has agreed to.
Beta Was this translation helpful? Give feedback.
All reactions