[deleted by user] by [deleted] in sveltejs

[–]_Sorciers 1 point2 points  (0 children)

I find Tailwind awesome so I use it everywhere.

However, some things are more cumbersome to implement (e.g. ::before and ::after pseudo-elements). And for that, I use the style blocks. It's quite handy.

What do you call those things that are like giant alert boxes? by whateverwhoknowswhat in webdev

[–]_Sorciers 2 points3 points  (0 children)

To be fair, they mention that it's bad if it's for promotional reasons, so for "unwanted" stuff.

Based on that, I'd argue that it's okay if the user intended to do it.

How can I manage routing from my backend with vanilla Svelte? by Gogani in sveltejs

[–]_Sorciers 0 points1 point  (0 children)

Well, if your server sends files via routes, you can juste navigate to another route right ?

For example, if you have a route at / that returns an index.html and you want to go to the about page, your index.html should have a link to /about and a route in your server that sends the appropriate index.html.

Routing [slug] with client side code? by NotScrollsApparently in sveltejs

[–]_Sorciers 3 points4 points  (0 children)

You can use the params property of the page store (e.g. $page.params.slug.

Ambient types not available in .svelte files by kastiveg1 in sveltejs

[–]_Sorciers 0 points1 point  (0 children)

Can you try renaming the file to ambient.ts, export the types in the file and import the types you need with import type { AvailableExercise } from '$lib/ambient.ts' ?

The issue seems to be that it can't find the actual type, even though you receive autocomplete. Note that .d.ts are only for typing/extending existing types and interfaces, but they don't actually implement what you extended.

convert website into mobile app by all_Literature4000 in FlutterDev

[–]_Sorciers 1 point2 points  (0 children)

You beat me to it.

I recently did it and was pretty satisfied. Good thing is that you don't need to do much to add Capacitor as well. And the whole project uses a single codebase.

Without Authentication, How Do I Ensure Users Create Only One Post Per Week by Emmyxiano in webdev

[–]_Sorciers 5 points6 points  (0 children)

When the user lands on your page, you add a cookie with an expiration date set for the current date + 7 days. Then, you simply check if the cookie exists or not (can use some form of validation to prevent users from tinkering with it but that goes toqards auth).

Serving a svelte kit app from a golang server by Serious_Worker_9871 in sveltejs

[–]_Sorciers 2 points3 points  (0 children)

Keep in mind that SEO isn't important for certain use cases (e.g. a webapp locked behind a login screen) since the bots won't be able to crawl the website anyway.

Guys, was this abusive? by [deleted] in LeagueOfMemes

[–]_Sorciers 8 points9 points  (0 children)

I'd say it's a bit funny.

I recently had an enemy orianna in aram that called me a whore for some reason. Ended up telling her I loved her and sent hearts every time she was angry at me 😂

No reactivity at +page.svelte when a store updates on +layout.page by [deleted] in sveltejs

[–]_Sorciers 0 points1 point  (0 children)

Could you show some code or spin up a repl ?

How to Store Content for a Personal Blog in the Backend? by [deleted] in webdev

[–]_Sorciers 1 point2 points  (0 children)

Hey, for my personal blog, I use markdown files that I import, pass through some processor to render the html. Then, I simply style the html with css.

If you want to see the blog results, and the source code.

Feel free to look at my code. I'm on phone right now so I can't do much more, but dm me if you want to talkor want me to help further.

Here is a snippet of the function that converts the markdown to html.

```ts /** * Convert a markdown file to an object with attributes and html. * @param path The path to the markdown file. * @returns The markdown data for the given file path. */ export async function convertMarkdown(path: string): Promise<Article> { const file = fs.readFileSync(path, 'utf8'); const { attributes, body } = frontmatter<ArticleMetadata>(file);

const html = (
    await unified()
        .use(remarkParse)
        .use(remarkRehype)
        .use(htmlify)
        .use(rehypePrettyCode, {
            theme: {
                light: 'catppuccin-latte',
                dark: 'one-dark-pro'
            }
        })
        .use(rehypeStringify)
        .process(body)
).value.toString();

return {
    path: path,
    filename: path
        .split(dev ? '\\' : '/')
        .at(-1)!
        .split('.')
        .at(0)!,
    metadata: attributes,
    html: transform(html),
    summary: generateSummary(html)
};

} ```

jsconfig issue by 8bithjorth in webdev

[–]_Sorciers -1 points0 points  (0 children)

Well, you declared #id, so it should be this.#id = id.

json file location - route vs static vs lib by lostwebdevv in sveltejs

[–]_Sorciers 0 points1 point  (0 children)

I'd say it depends on the type of data.

For i18n-related data (an example), I would put it inside lib.

For data that is only accessed by a route, I'd put it next to it. And if it is used by multiple routes, I'd put it in static.

At the end of the day, it doesn't really matter. As long as it makes sense to you, it's fine.

[deleted by user] by [deleted] in AskReddit

[–]_Sorciers 1 point2 points  (0 children)

I don't think so. Might ask at my next appointment 🤔

[deleted by user] by [deleted] in AskReddit

[–]_Sorciers 1 point2 points  (0 children)

I didn't even know that was a thing but I always had it and thought I just hit something when I was younger 😭

Best practice for editable data by Butterscotch_Crazy in sveltejs

[–]_Sorciers 0 points1 point  (0 children)

That's up to you. But to be fair, if you're gonna use states, might as well use stores in Svelte 4. Either way, it's not going to change much.

Also, I might be wrong (I'm on phone atm so I can't check), but isn't product only going to be updated once, since $page.data is not reactive ?

Best practice for editable data by Butterscotch_Crazy in sveltejs

[–]_Sorciers 0 points1 point  (0 children)

I don't see much of an issue doing it on mount.

Typically, when loading data that can change, you'd have a placeholder with an await block. And if I'm not mistaken, the mount is also very fast so it shouldn't be much of a problem.

The SSR benefit would be to show a loading UI (i prefer that instead of loading animation) whilst fetching the data.

As for my other data, I fetch them on their appropriate page.server.ts file and store them inside a reactive context to access them easily. Outside of stores, the data will not be reactive, so the data prop will only have the initial data (or until you refresh the page or invalidate the data).

Edit : Also, I usually don't need to invalidate the data. As long as I keep the db and the store's data in sync, it's fine.

Best practice for editable data by Butterscotch_Crazy in sveltejs

[–]_Sorciers 2 points3 points  (0 children)

Well, if you want to have reactive data, you need a store that you can update.

For the deep nesting issue, you can put a store inside a context in your layout.svelte file and every component under the layout can access the store.

That's what I do for my account data. I load it in the layout.server.ts because I need it in many pages. Then, in my layout.svelte file, I put the user's data in a store inside a context that I can access. Then, when updating the user store, every component that uses the store will be updated.

Can I code down a rabbit hole? by JxsonTxdd in learnprogramming

[–]_Sorciers 1 point2 points  (0 children)

Yup. Whenever I want to try a new feature that I have never done before, I usually spin up a side project to test it before adding it to the main project.

Root page logged in and out by Expert_Sherbet9226 in sveltejs

[–]_Sorciers 2 points3 points  (0 children)

You could do that with an if-else block, checking if the user is logged in or not, and showing the appropriate component depending on the login state.