Closed rufuspollock closed 1 year ago
Used this so far Use https://github.com/lonekorean/wordpress-export-to-markdown
Current CLI setup:
@khalilcodes Just some problems that came up while testing the current tool
https://www.datopian.com/wp-content/uploads/2021/01/Group-4298_desktop.svg
@khalilcodes also my headings seems to display correctly when using flowershow, so I think the problem lies in the new datopian version and not the exports.
@PhilippeduPreez
hardcoded values to OG website like https://www.datopian.com/wp-content/uploads/2021/01/Group-4298_desktop.svg
This is why i think brute force migrating wp-content/uploads
into the public folder is good idea (i've had this experience before). Can you get a wp-content/uploads
export out of wordpress?
I'd also frankly do that with the images if you could and not bother rewriting them.
Some custom stuff like tables do not convert
this is fine. Just flag that in the tutorial / docs.
@rufuspollock @PhilippeduPreez Since wordpress users are already aware of plugins, how about just using a free export wordpress plugin like https://wordpress.org/plugins/export-media-library/ and just putting that in the tutorial section eg. "exporting your wordpress assets" ?
@khalilcodes @rufuspollock I agree that we might need to go the export wordpress plugin route to match the correct folder structure. Exporting the media in xml and using https://github.com/lonekorean/wordpress-export-to-markdown will not produce any images as it only work on exporting "All content"
@PhilippeduPreez pushed the changes to script we worked on. Note that the images folder now generates within the (output) directory. Also please confirm .svg
path outputs.
Although we discussed, I'm not convinced if we should be prepending assets like so [](assets/images/...)
since the assets folder could be named anything else in flowershow. What do you think ?
Other than that I think the html in frontmatter's title field would be left to look at and then we may have a ready to go script.
@khalilcodes another option to [](assets/images/...)
could be to turn image links into wikilinks since they should be picked up anywhere in content folder as far as I understand. Then we don't need to specify an assets folder
@khalilcodes just and idea for future users we could ask the name of their assets folder in the wizard and append that before like
[ ](name-of-assets-folder/images/...)
@PhilippeduPreez pushed the tests.
@khalilcodes The date frontmatter ordering works, so we don't need to make any changes to the type
@khalilcodes @rufuspollock Links like these [on the value of data](https://www.datopian.com/2022/04/07/on-the-value-of-data/)
will still cause problems atm. The tool is able to currently output year and month folders, so maybe we can add a day folder so these links will be functional?
@rufuspollock I confirmed with @olayway that the new flowershow blog setup should handle this correctly, then these links should still work
@PhilippeduPreez I came across two changes and opened a PR for your review on these.
Fix to titles being converted directly as slugs as seen below:
Renaming the coverImage
field to image
in frontmatter. Since an image field is already present in flowershow blog/page definition, let's use that rather than separately adding a coverImage
field in contentlayer.
@khalilcodes I opened a PR for your review on authors being added in frontmatter
@PhilippeduPreez, @khalilcodes please update the tasks in the description and add relevant comments :)
@PhilippeduPreez if the PR you created will close this issue you can link the PR by adding Closes #<number of this issue>
to its description.
@PhilippeduPreez @olayway @rufuspollock One issue with images I have faced during migration is with the paths to any image files.
In Obsidan, we would write the path to the images like so - ![](assets/images/example.png)
. This then shows up the image but fails to load on the web since the path resolves as relative. for eg. <img src="https://next.lifeitself.org/<sub-dir>/assets/images/example.png" />
For it to load on the web, we would need to add a leading slash - ![](/assets/images/example.png)
, but then this fails to load in Obsidian.
To fix this issue we can modify the img
tag in MDX.js
to add a leading slash for local images (if they don't already have one) like below:
// in MDX.js
const components = {
img: ({ src, ...rest }) => {
// check if the image path is external or already has a leading slash
const imageSrc = src.startsWith("http") || src.startsWith("/") ? src : `/${src}`
return <img src={imageSrc} {...rest} />
}
...
}
I believe we should backport this which will then allow users consistency as to being able to view the images in Obsidian as well as on the website.
Note: that wiki-links-plus already prepends a slash and that's why we probably never noticed this. This issue is more likely to happen when either converting from wordpress or for users who use the markdown image syntax. IMO consistency across platforms remain.
Let me know your thoughts :)
In Obsidan, we would write the path to the images like so -
Hmmm... but aren't we using this syntax for embedding local images in Obsidian? ![[<image file name>]]
Oh, right, but we probably don't want to convert it to Obsidian wiki links since the user might not be using Obsidian.
@PhilippeduPreez @khalilcodes can you confirm how we handled assets other than images (e.g. pdfs etc) in the wp-content folder? Does that stuff get migrated (especially relevant for life itself migration #261 )
@rufuspollock I had updated the code locally to download pdfs into the assets/
folder (not in assets/images/) and parse the paths in markdown. If that sounds right, I can push the code to the tool and include the pdfs in the PR here https://github.com/life-itself/community/pull/212
Closed with #336
When on wordpress i want to switch to flowershow / nextjs because it is awesome so that i can maintain my site more easily etc
After running output is something like this:
Acceptance
assets/images/
ormy-assets/images/
the name of the assets folder is configurableTasks
Tutorial
Tool
Bonus
Notes
npx flowershow --convert-wordpress
? ❌2022-11-21. No assume this is a standalone script for now so we don't "pollute" flowershow cli with misc stuffBlog setup in flowershow
Current fields:
Question
Change authors field type from https://www.contentlayer.dev/docs/reference/source-files/field-types#list
to
Needed fields
Other changes
Current script output:
Changes in script
coverImage
field in blog definition type or modify script to changecoverImage
toimage
[#](...link to heading)
. convert to only headings, because we have them added by default in flowershow usingrehypeAutolinkHeadings
.Assets
Current folder output
Modify script to below changes:
post
toblog
./